Vagrant SSH Tunnelling after using `vagrant ssh`

16,502

Solution 1

I got around this issue by using port forwarding instead of SSH tunnelling. I added the following to Vagrantfile:

config.vm.network :forwarded_port, guest: 3306, host: 8306

Then connected to MySQL via port 8306.

Solution 2

I had the same problem, and it turned out to be an old key in my known_hosts file.

So, I did:

$ vi ~/.ssh/known_hosts

went to the line with 127.0.0.1:2200 on it, then did command dd to delete that line.
:x to save, and bam bob's yer uncle. Connection granted, long live Jambi.

I hope that saves someone some grief. Cheers.

Solution 3

I had the similar issue. I struggled for whole day. I even went through Vagrant and Sequel Pro by Jeffrey Way. Still had a problem. I even changed forwarding port number in Vagrant file and did everything possible. But, the following saved my life.

When I did vagrant reload than I saw

  default: 22 => 2200 (adapter 1)

But, What I was doing was when setting up connection in sequel pro I had written SSH PORT: 2222 I did this based upon the video from the above link. But as soon as I changed to the number I saw with vagrant reload than it asked me for verification. I did select 'YES'. And, it did get connected. Happy ending after a day of struggle. Its for future readers,hopefully someone somewhere won't have to spend a day like me for this reason. ;)

Solution 4

Try to load the another key from folder with vagrant project
E.g. {vagrant_project}/.vagrant/machines/default/virtualbox/private_key

Share:
16,502
Small Hadron Collider
Author by

Small Hadron Collider

Updated on July 22, 2022

Comments

  • Small Hadron Collider
    Small Hadron Collider almost 2 years

    My MySQL client (Sequel Pro) is set up to connect to Vagrant over SSH. I've setup the following in my ~/.ssh/config file:

    Host vagrant
      HostName 127.0.0.1
      CheckHostIP no
      Port 2222
      User vagrant
      IdentityFile ~/.vagrant.d/insecure_private_key
    

    Everything works fine if I haven't run vagrant ssh. But once I've logged into the Vagrant box with that command Sequel Pro can no longer connect via SSH - it just says "The SSH Tunnel has unexpectedly closed." So I have to run vagrant reload before I can connect to the MySQL server.

    Does anyone know how to get around this issue?