Author Li Wanpeng
If you want to access the virtual machine on the server, you can use vncviewer to first log in to the server and then operate VMM (virtual machie manager, QEMU). This is troublesome. We can directly log on to the guest OS in a simpler way.
First, add the ssh configuration file to the home directory:
Hacker @ hacker :~ $ Cat. ssh/config
Host 9.186.9.18
User liwp
LocalForward localhost: 4444 192.168.122.156: 22
LocalForward localhost: 6666 FIG: 5902
Here 9.186.9.18 is the server address, liwp is my account on the server, 4444,6666 is the port on my localhost, and 192.168.122.156 is the ip address of the guest OS, 22 is the port used by ssh on the guest OS. 5902 is the VNC server port opened by the VMM. For example:
If the ssh configuration file is successfully added, We can log on.
Two step:
1. log on to the server using ssh
2. In another window:
1) log on to guest OS through the command line
Ssh-p 4444 localhost-l liwp
2) log on to guest OS with vncviewer
Vncviewer localhost: 6666
If you are in the libmongod group, you can use the VMM of localhost to directly run the virtual machine on the remote server instead of running it on the server.
[Liwp @ chinaltcdragon ~] $ Id liwp
Uid = 507 (liwp) gid = 507 (liwp) group = 507 (liwp), 512 (admin), 516 (libvirt)
Three step:
1. admin adds you to the libmongod Group
Usermod-G libvirtd xxxx
2. add connection.
OK! Well done! You can operate your VM on your localhost.