Score:0

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

ph flag

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?
cocomac avatar
cn flag
Please don't ask multiple questions at once. Instead, ask multiple separate questions. You can link to different question if it helps to provide context, but please ask each question separately.
Score:0
cn flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.