我停止并重新启动了一个 ubuntu 14.04 Google Cloud Compute Engine 实例,现在我的 ssh 连接被拒绝:ssh: connect to host 146.148.114.98 port 22: Connection refused
这已经发生过一次,我以为机器有问题,我删除了它并重新创建,然后它又开始工作了。我不想每次都重新创建实例。谷歌云的ssh疑难解答页面比较乱。我的防火墙规则似乎没问题。任何人都有解决方案?
NAME NETWORK SRC_RANGES RULES SRC_TAGS TARGET_TAGS
default-allow-http default 0.0.0.0/0 tcp:80 http-server
default-allow-https default 0.0.0.0/0 tcp:443 https-server
default-allow-icmp default 0.0.0.0/0 icmp
default-allow-internal default 10.128.0.0/9 tcp:0-65535,udp:0-65535,icmp
default-allow-rdp default 0.0.0.0/0 tcp:3389
default-allow-ssh default 0.0.0.0/0 tcp:22
这是输出:
ps aux | grep ssh
root 29 0.0 0.4 55184 2860 ? Ss 11:26 0:00 /usr/sbin/sshd -p 22 -o AuthorizedKeysCommand=/google/devshell/authorized_keys.sh -o Author
izedKeysCommandUser=root
root 183 0.0 0.9 82692 5940 ? Ss 11:26 0:00 sshd: fbeshox [priv]
fbeshox 218 0.0 0.7 82692 4424 ? S 11:26 0:00 sshd: fbeshox@pts/0
fbeshox 522 0.0 0.3 12728 2200 pts/1 S+ 12:12 0:00 grep ssh
这里是 ssh 连接尝试的详细结果。
ssh -i .ssh/keyname username@130.211.53.51 -vvv
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/xxxx/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 102: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 130.211.53.51 [130.211.53.51] port 22.
debug1: connect to address 130.211.53.51 port 22: Connection refused
ssh: connect to host 130.211.53.51 port 22: Connection refused
最佳答案
可能是 sshguard
是默认安装在 Ubuntu 上的安全工具,它会干扰您的连接。基本上 sshguard 可能错误地认为您的 IP 地址正在“攻击”您的实例并阻止了 IP。
如果您可以从其他位置登录,例如 Cloud Console 提供的 Web SSH,请尝试使用 sudo iptables -S
查看 sshguard 创建的实例(不同于 GCE 防火墙)上是否有任何防火墙规则。如果是这样,请尝试禁用 sshguard 或将您的 IP 地址添加到白名单 ( http://www.sshguard.net/docs/whitelist/ )。
关于ssh - 为什么 Google Cloud Compute Engine 实例在重启后拒绝 ssh 连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38037802/