我在Google云端平台上安装了两个虚拟机。 server1使用Ubuntu 16.04映像[g1-small(1 vCPU,1.7 GB内存)]; 而新创build的名为server2 VM使用CoreOS稳定映像[f1-micro(1 vCPU,0.6 GB内存)]。
主要的问题是我无法连接到server2即使我使用相同的SSH密钥和用户。
我将使用这个链接来比较ssh -v两个输出结果。
为了确保我testing了这个权利,我删除了文件/Users/userz/.ssh的文件google_compute_engine , google_compute_engine.pub , google_compute_known_hosts和来自known_hosts的内容。
然后执行命令gcloud init ,然后执行gcloud compute config-ssh ,它检测到没有SSH密钥,并且在请求密码而不是密码时通过创build新密钥来指导我。 这个新的SSH密钥是在这个testing中使用的。
如果你看到server1的第一个链接,ssh最终会询问密码。 但是对于server2 ssh最终会要求input一个密码,这与input的内容无关,每次input都是错误的。
我尝试的密码是:相同的密码,我的谷歌帐户的login密码,本地机器的pipe理员密码,以及我记得使用的其他任何密码。 而错误的input。
当我使用相同的方法连接到虚拟机时,为什么会有这种差异? 我可以做些什么来解决这个问题,因为我不知道也没有在server2 (新创build)上设置任何密码?
我可以补充说明,通过Cloud Shell连接请求密码并轻松连接。
server1输出:
ssh -v server1 OpenSSH_7.4p1, LibreSSL 2.5.0 debug1: Reading configuration data /Users/userz/.ssh/config debug1: /Users/userz/.ssh/config line 51: Applying options for server1 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to XXX.XXX.XX.XX [XXX.XXX.XX.XX] port 22. debug1: Connection established. debug1: identity file /Users/userz/.ssh/google_compute_engine type 1 debug1: key_load_public: No such file or directory debug1: identity file /Users/userz/.ssh/google_compute_engine-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.4 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 pat OpenSSH* compat 0x04000000 debug1: Authenticating to XXX.XXX.XX.XX:22 as 'userz' debug1: using hostkeyalias: compute.hostkeyaliasX debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: [email protected] debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx debug1: using hostkeyalias: compute.hostkeyaliasX debug1: Host 'compute.hostkeyaliasX' is known and matches the ECDSA host key. debug1: Found key in /Users/userz/.ssh/google_compute_known_hosts:1 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey after 134217728 blocks debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /Users/userz/.ssh/google_compute_engine debug1: Server accepts key: pkalg rsa-sha2-512 blen 279 Enter passphrase for key '/Users/userz/.ssh/google_compute_engine':
server2输出:
ssh -v server2 OpenSSH_7.4p1, LibreSSL 2.5.0 debug1: Reading configuration data /Users/userz/.ssh/config debug1: /Users/userz/.ssh/config line 43: Applying options for server2 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to YY.YYY.YYY.YYY [YY.YYY.YYY.YYY] port 22. debug1: Connection established. debug1: identity file /Users/userz/.ssh/google_compute_engine type 1 debug1: key_load_public: No such file or directory debug1: identity file /Users/userz/.ssh/google_compute_engine-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.4 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4 debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000 debug1: Authenticating to YY.YYY.YYY.YYY:22 as 'userz' debug1: using hostkeyalias: compute.hostkeyaliasY debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy debug1: using hostkeyalias: compute.hostkeyaliasY debug1: Host 'compute.hostkeyaliasY' is known and matches the ECDSA host key. debug1: Found key in /Users/userz/.ssh/google_compute_known_hosts:3 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey after 134217728 blocks debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Next authentication method: publickey debug1: Offering RSA public key: /Users/userz/.ssh/google_compute_engine debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Next authentication method: keyboard-interactive Password:
~/.ssh/config文件。 如果不是,你可能会有一段糟糕的时光。 这是通过删除gcloud所做的configuration来解决的
gcloud compute config-ssh --delete
之后,重新安装运行与问题中所述相同的命令的configuration:
gcloud compute config-ssh