0

I've set up two vm running on same virtualbox host, they are working under same NAT Network and each has grained an IP. Their network setting looks like: ifconfig outputs network setting from Virtualbox GUI

In order to make SSH works, I've followed instruction of this thread, and my port forward setting looks like: Port Forward setting of NAT network The ssh_config and their network interface are default, default network interface looks like:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

the ssh_config looks like:

Host *
#   ForwardAgent no
#   ForwardX11 no
#   ForwardX11Trusted yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519
#   Port 22
#   Protocol 2
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,[email protected]
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes

The ping command between these two vm works perfectly ok, but whenever I tried to ssh from PC-3 into PC-2, it keeps failing. I tried to uncomment the port 22 in ssh_config on PC-2, which produce the same fail result. My ssh with debug output looks like: ssh failed result

Can someone points out what mistake I've made in setting that causes the ssh failure? Thanks in advance.

6
  • well, I always add two vNICs - one NATted for Internet access, the second a Host-Only adapter which I use for ssh from my laptop to the VM.
    – Zina
    Commented May 7, 2020 at 21:07
  • @Zina hmmm, but this is ssh communication between 2 vms, could you reference the source of vNIC setting pls? Commented May 7, 2020 at 21:10
  • 1
    just have re-read your whole post if ping works between the two VMs you should be able to ssh from one to another with plain ssh on port 22, no port forwarding needed. the port forwarding is needed if you want to ssh form another PC in your network to the VM on your PC and you need to use the IP form your PC as host IP
    – Zina
    Commented May 7, 2020 at 21:15
  • @Zine, I tried both with and without port forwarding, but I got ssh: connect to host 10.0.2.5 port 22: Connection refused. Commented May 7, 2020 at 21:27
  • yeah, sorry, so I have two network cards configured on each VM, the first one as NAT as yours, and the second one you create a host-only. for this you need to set up a netowrk in the hist network manager, I for eg used a DHCP enabled 192.168.56.x/24 network. I am running VirtualBox on macOS.
    – Zina
    Commented May 7, 2020 at 21:32

1 Answer 1

0

I resolved the issue by installing ssh servers. sudo apt install openssh-server

You must log in to answer this question.

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