首页 文章

为什么Google Cloud Compute Engine实例会在重启后拒绝ssh连接?

提问于
浏览
2

我停止并重新启动了ubuntu 14.04 Google Cloud Compute Engine实例,现在我的ssh连接被拒绝了:

ssh: connect to host 146.148.114.98 port 22: Connection refused

这已经发生在前一次,我以为机器有问题,我删除了它并重新创建它再次开始工作 . 我不想每次都重新创建实例 . 谷歌 Cloud 的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

5 回答

  • 1

    sshguard (默认情况下安装在Ubuntu上的安全工具)可能会干扰您的连接 . 基本上sshguard可能错误地确定您的IP地址是您的实例并阻止了IP .

    如果您可以从其他位置登录,例如 Cloud 控制台提供的Web SSH,请尝试使用 sudo iptables -S 查看sshguard创建的实例(不同于GCE防火墙)是否存在防火墙规则 . 如果是,请尝试禁用sshguard或在whitlelist上添加您的IP地址(http://www.sshguard.net/docs/whitelist/) .

  • 0

    我知道这是一个老问题,但今天我有类似的问题,问题很简单 - 重启后实例的IP也发生了变化 - 所以我不得不相应地更新ssh字符串

  • 3

    尝试使用不同的用户名SSH进入实例.Google Compute有时会有点不稳定 . 尝试使用Compute Engine中的VM实例页面SSH进入实例 . 如果SSH花费太多时间并拒绝连接,则使用SSH中的其他用户名登录 . 您可以使用SSH窗口右上角的设置图标以不同的名称登录 . 如果所有这些都不顺利,我会建议你重新创建一个实例,因为我的经验是Google Compute Engine实例在SSH可访问性方面不稳定并且往往会产生问题 . 这样做更好 . 使用putty作为客户端SSH到计算引擎,而不是谷歌提供的SSH终端 . 让我知道,如果这有助于你:)

  • 0

    我知道在机器停止并安装了该磁盘后从控制台分离磁盘后引发了我的问题 . 首先卸载磁盘,然后将其分离 . 从未见过这个问题 .

  • 0

    更改默认区域或区域后,通常会发生此问题 . 然后,您必须通过sudo gcloud compute config-ssh更新元数据中的ssh密钥

    您还可以在Compute Engine |下看到Web界面中的更改元数据| SSH密钥 .

相关问题