I have to ssh into two VMs. The first VM is configured to be sshed into via port 22 by default. But what changes do I make and where to ssh into second VM from host terminal. even when I close the first VM login, I cannot ssh into VM_2 via port-22.

I'm using the command

ssh vm_2@ip_address -p port_number  


Error msg:

ssh: connect to host 192.xxxxxxxxxxx port 22: Connection refused
  • So you're trying to connect from VM1 to VM2?
    – Panki
    Commented May 12, 2020 at 10:30
  • What host are you trying to connect to vm2 from? What happens when you try? Do you get error messages? What do they say?
    – Kenster
    Commented May 12, 2020 at 11:44
  • @Kenster i'm trying to connect vm_2 form host terminal. and edited the question. pls see error msg.
    – y_159
    Commented May 12, 2020 at 12:05
  • @Panki No i've to connect vm_2 from host
    – y_159
    Commented May 12, 2020 at 12:08
  • I've created these vms from virt-manager.
    – y_159
    Commented May 12, 2020 at 12:11

1 Answer 1


You need to run sshd on your VM on a different port. If port 22 is bound to your host machine on the same port, then you must bind port 22 in your other VM to some other port on your host machine. Assuming you are using a sane VM client like VirtualBox, you should be able to do this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .