Windows / Vagrant / Ubuntu
This is what worked for me and you can quickly figure out if this will work by running this on the ssh client.
ssh vagrant@127.0.0.1 -p 2222 -v
The -v
will put it in verbose mode and display debug info...
$ ssh vagrant@127.0.0.1 -p 2222 -v
OpenSSH_7.1p1, OpenSSL 1.0.2e 3 Dec 2015
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222.
debug1: Connection established.
debug1: identity file /home/Jamie/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Jamie/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Jamie/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Jamie/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Jamie/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Jamie/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Jamie/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Jamie/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to 127.0.0.1:2222 as 'vagrant'
debug1: SSH2_MSG_KEXINIT sent
Connection closed by 127.0.0.1
So... SSH2_MSG_KEXINIT
means the keys are being exchanged. This shortly fails...
In this case, I deleted my keys and regenerated them doing this on the VM. (http://ask.xmodulo.com/sshd-error-could-not-load-host-key.html)
$ ls -al /etc/ssh/ssh*key
$ sudo rm -r /etc/ssh/ssh*key
$ sudo dpkg-reconfigure openssh-server
Once my keys were regenerated I was able to SSH into my Vagrant Box.