Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant SSH Tunnelling after using `vagrant ssh`

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?

like image 573
Small Hadron Collider Avatar asked Mar 12 '14 12:03

Small Hadron Collider


People also ask

How do I exit vagrant ssh?

Vagrant SSH Once you are done exploring the virtual machine, you can exit the session with CTRL-D.

How do I destroy vagrant machine?

Command: vagrant destroy [name|id] This command stops the running machine Vagrant is managing and destroys all resources that were created during the machine creation process. After running this command, your computer should be left at a clean state, as if you never created the guest machine in the first place.


2 Answers

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.

like image 173
Ian Ring Avatar answered Oct 18 '22 06:10

Ian Ring


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.

like image 15
Small Hadron Collider Avatar answered Oct 18 '22 05:10

Small Hadron Collider