Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

How to login into VM from host which is a remote server?

Writer Sebastian Wright

My host machine is a remote server on which I created a VM using qemu. I created the VM using the following command:

./qemu-system-x86_64 -hda /home/divija/images/xenial-server-cloudimg-amd64-disk1.img -cdrom /home/divija/images/ubuntu-16.04.6-server-i386.iso -m 8G -boot d -smp 4 -monitor stdio -net user,hostfwd=tcp::2222-:22 -net nic

I see the result:

QEMU 2.9.91 monitor - type 'help' for more information
(qemu) VNC server running on 127.0.0.1:5900

Then, on a different terminal I try to login into the VM from the host via ssh

ssh -p 5900 divija@localhost

But I get the error message:

 ssh_exchange_identification: Connection closed by remote host
  1. Should I login using port 2222 or 5900? Why is it being created on 5900 when I explicitly gave 2222?
  2. Is there a way to login to the VM without port forwarding?
1

1 Answer

i'm not sure about question 1 since i have never used qemu but i think you might be trying to ssh into a vnc server (your output on the vm says: VNC server running on 127.0.0.1:5900 and i might be wrong again but i dont think you can ssh into a vnc server. you can use Putty to connect to vnc servers.

for question 2 i suggest you use ngrok to forward port 5900, so for example running this on the vm: ngrok tcp 5900 would allow you to access that port from beyond your local network.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy