使用`vagrant ssh`之后的Vagrant SSH隧道 [英] Vagrant SSH Tunnelling after using `vagrant ssh`
问题描述
我的MySQL客户端(Sequel Pro)已设置为通过SSH连接到Vagrant.我在~/.ssh/config
文件中设置了以下内容:
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
如果我没有运行vagrant ssh
,一切都很好.但是,一旦我使用该命令登录Vagrant框,Sequel Pro就无法再通过SSH连接-它只是说"SSH隧道已意外关闭".因此,必须先运行vagrant reload
,然后才能连接到MySQL服务器.
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?
推荐答案
我通过使用端口转发而不是SSH隧道解决了这个问题.我在Vagrantfile
中添加了以下内容:
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
然后通过端口8306
连接到MySQL.
Then connected to MySQL via port 8306
.
这篇关于使用`vagrant ssh`之后的Vagrant SSH隧道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!