问题描述
我配置了vagrant以启动ubuntu VM。然后,我将VM配置为具有2个ssh端口(SSH服务应在2个不同的端口上运行)。
这是我的/ etc / ssh / sshd_config更改-
Port 22
Port 9000
vagrant@vagrant-ubuntu-trusty-64:~$ sudo vi /etc/ssh/sshd_config
vagrant@vagrant-ubuntu-trusty-64:~$ sudo ufw allow 9000/tcp
Rules updated
Rules updated (v6)
vagrant@vagrant-ubuntu-trusty-64:~$ sudo service ssh restart
ssh stop/waiting
ssh start/running,process 2059
vagrant@vagrant-ubuntu-trusty-64:~$ ss -tnlp | grep -E "22|9000"
LISTEN 0 128 *:22 *:*
LISTEN 0 128 *:9000 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 :::9000 :::*
我运行ufw允许在VM上打开9000,然后确保22和9000端口都可用于SSH。
然后,我没有更改Vagrantfile上的任何内容,只运行了“无用重载”-
MacBook-Pro:~ sg$ vagrant reload
==> default: Attempting graceful shutdown of VM...
default: Guest communication Could not be established! This is usually because
default: SSH is not running,the authentication @R_162_4045@ion was changed,default: or some other networking issue. Vagrant will force halt,if
default: capable.
==> default: Forcing shutdown of VM...
==> default: Checking if Box 'ubuntu/trusty64' version '20190514.0.0' is up to date...
==> default: Clearing any prevIoUsly set forwarded ports...
==> default: Clearing any prevIoUsly set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection reset. retrying...
default: Warning: Remote connection disconnect. retrying...
default: Warning: Connection reset. retrying...
default: Warning: Remote connection disconnect. retrying...
为什么到VM的SSH连接失败?除非运行无用的破坏和无用的操作,否则无法再次访问VM。我还尝试过将portforwarding更改为指向另一个ssh端口,但这是另一个问题。我在这里做什么错了?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)