Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 562  / 2 Years ago, wed, july 27, 2022, 3:53:45

How can I access virtual machine in KVM without ssh, ssh port is disabled and I want to enter the virtual machine and enable it. I tried virsh console and VNC solutions , they did not work because it is not enabled from inside. It seems it is impossible to enter the virtual machine. IS there any way to enter?


More From » server

 Answers
4

The easiest method to access virtual machine consoles is the program called virt-manager. It is a GUI program that is an "all in one" solution to manage virtual machines in general - create, modify, start/stop them etc.


You may have virt-manager already installed on your server as a part of KVM installation. If not, install it as you usual install any software, using the command


sudo apt install virt-manager

You should run virt-manager with root privileges (otherwise it may have trouble communicating with libvirtd daemon on your machine), ie.


sudo -b virt-manager

(the -b parameter to sudo tells to run the program in background - as GUI programs are usually run - to avoid blocking the terminal).


The program is basically self-explanatory and you can easily access the VM console with it.


However, because it is a GUI program, the tricky part is how to get it running on a remote server that you access via SSH (I suppose so, because you didn't specify exactly how do you access the server).


Running a GUI program on a remote server requires two things:



  1. an X server running on the local machine (from which you SSH to the server), to be able to display the GUI, and

  2. configured X forwarding over SSH between remote and local machine.


As for 2), you need to edit the file /etc/ssh/sshd_config on your server and check if it contains a line that says


X11Forwarding yes

It usually doesn't, so you have to add that line and save the modified file (note: you must do it as root, eg. use sudo to call your preferred editor on the file). After this, you need to restart the ssh service:


sudo service ssh restart

As for 1) the easiest case is when your local machine is also a Linux machine, as it already has a X server running to operate its local GUI :). In that case you don't need to do anything special besides adding a -X parameter to ssh command when you connect to the server:


ssh -X youruser@yourserver

The -X parameter tells ssh to forward the GUI over SSH to the local X server, so the program running on server will display its GUI on your local computer.


If your local machine is a Windows machine, then you need to install locally some software that provides the X server functionality (for example Xming). After X server is started, you need to tell your SSH client to forward the GUI. The exact way how to do it depends on the SSH client you use.


If you are using the built-in ssh command in Windows 10/11, it should support the -X option similarly to the Linux one (but I haven't tested it).


If you are using PuTTY (which is probably the most popular SSH client for Windows), before opening the connection you should go to Connection -> SSH (click "+" to expand) -> X11 in the options screen, and then tick the check box "Enable X11 forwarding" - this is equivalent to specify the -X parameter in ssh command (I have tested it and can confirm it works).


Below you can see a screenshot of virt-manager accessing a VM console on the server (the server in this case is CentOS, the local machine is a quite old version of Ubuntu, the VM is OpenWRT :)) :


enter image description here


[#51] Thursday, July 28, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
afisird

Total Points: 193
Total Questions: 112
Total Answers: 111

Location: Angola
Member since Mon, Jul 12, 2021
3 Years ago
afisird questions
Sun, Mar 12, 23, 18:05, 1 Year ago
Sun, Dec 11, 22, 01:19, 1 Year ago
Sun, May 1, 22, 18:56, 2 Years ago
;