前面我们讲了如何通过vnc连接虚拟机,那么本节我们讲下如何通过命令行来进入虚拟机,我们可以查看IP地址,然后通过ssh进行连接
[root@kvm ~]# ssh root@10.1.100.137
The authenticity of host '10.1.100.137 (10.1.100.137)' can't be established.
RSA key fingerprint is 71:fd:92:67:72:c6:02:45:cb:e7:66:0b:94:28:34:68.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.1.100.137' (RSA) to the list of known hosts.
root@10.1.100.137's password:
Last login: Sun Mar 19 18:14:55 2017
但是,我们接下来要讲的是如何通过console去连接,我们开始了
参数配置
1.添加 ttyS0
[root@vm1 ~]# echo "ttyS0" >> /etc/securetty
2.修改grup.conf文件
3.编辑/etc/inittab
4.reboot 重启
5.使用virsh console 连接虚拟机
[root@kvm ~]# virsh console vm1
Connected to domain vm1
Escape character is ^]
Welcome to CentOS
Starting udev: G[ OK ]
Setting hostname vm1: [ OK ]
Setting up Logical Volume Management: 2 logical volume(s) in volume group "vg_vm1" now active
[ OK ]
Checking filesystems
Checking all file systems.
[/sbin/fsck.ext4 (1) -- /] fsck.ext4 -a /dev/mapper/vg_vm1-lv_root
/dev/mapper/vg_vm1-lv_root: clean, 23063/558624 files, 268228/2230272 blocks
[/sbin/fsck.ext4 (1) -- /boot] fsck.ext4 -a /dev/sda1
/dev/sda1: clean, 38/128016 files, 57869/512000 blocks
[ OK ]
Remounting root filesystem in read-write mode: [ OK ]
Mounting local filesystems: [ OK ]
Enabling /etc/fstab swaps: [ OK ]
Entering non-interactive startup
Starting monitoring for VG vg_vm1: 2 logical volume(s) in volume group "vg_vm1" monitored
[ OK ]
ip6tables: Applying firewall rules: [ OK ]
iptables: Applying firewall rules: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:
Determining IP information for eth0... done.
[ OK ]
Starting auditd: [ OK ]
Starting system logger: [ OK ]
Mounting filesystems: [ OK ]
Retrigger failed udev events[ OK ]
Starting kdump:[FAILED]
Starting sshd: [ OK ]
Starting postfix: [ OK ]
Starting crond: [ OK ]
CentOS release 6.8 (Final)
Kernel 2.6.32-642.el6.x86_64 on an x86_64
vm1 login: root
Password:
Last login: Sun Mar 19 18:27:09 on tty1
[root@vm1 ~]#