Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ssh 在Google Compute上设置外部授权密钥_Ssh_Google Compute Engine_Google Cloud Platform - Fatal编程技术网

Ssh 在Google Compute上设置外部授权密钥

Ssh 在Google Compute上设置外部授权密钥,ssh,google-compute-engine,google-cloud-platform,Ssh,Google Compute Engine,Google Cloud Platform,我将从AWS迁移到Google云计算实例,并使用ansible进行部署。我正在尝试使用授权密钥在框上设置一些用户。这曾经适用于AWS,但对于Google Compute来说,用户管理似乎有点不同。这是我正在做的 在本地创建了ssh密钥。将此密钥(公共)放入ansible文件中,并将其复制到在/home/deploy/.ssh/authorized_keys 我仍然无法使用本地邮箱中的此密钥登录 $ ssh -i ~/.ssh/deploy_rsa deploy@<host> $ss

我将从AWS迁移到Google云计算实例,并使用ansible进行部署。我正在尝试使用授权密钥在框上设置一些用户。这曾经适用于AWS,但对于Google Compute来说,用户管理似乎有点不同。这是我正在做的

在本地创建了ssh密钥。将此密钥(公共)放入ansible文件中,并将其复制到在
/home/deploy/.ssh/authorized_keys

我仍然无法使用本地邮箱中的此密钥登录

$ ssh -i ~/.ssh/deploy_rsa deploy@<host>
$ssh-i~/.ssh/deploy\u rsa deploy@
是否有允许登录该框的用户列表?我可以只配置用户从云控制台登录到box吗

编辑

$ ssh -i ~/.ssh/deploy_rsa deploy@<host>
... skipped some logs here ....
    Here's SSH logs from client side:
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug2: key: /Users/ankit/.ssh/gcloud-rsa (0x7ff1d16105e0),
    debug2: key: /Users/ankit/.ssh/deploy_rsa (0x0), explicit
    debug1: Authentications that can continue: publickey
    debug3: start over, passed a different list publickey
    debug3: preferred publickey,keyboard-interactive,password
    debug3: authmethod_lookup publickey
    debug3: remaining preferred: keyboard-interactive,password
    debug3: authmethod_is_enabled publickey
    debug1: Next authentication method: publickey
    debug1: Offering RSA public key: /Users/ankit/.ssh/gcloud-rsa
    debug3: send_pubkey_test
    debug2: we sent a publickey packet, wait for reply
    debug1: Authentications that can continue: publickey
    debug1: Trying private key: /Users/ankit/.ssh/deploy_rsa
    debug3: sign_and_send_pubkey: RSA SHA256:h+yezPKOVjeA2ZKOAN/1r1GRe2s1nyGKwG6wobm+Vh0
    debug2: we sent a publickey packet, wait for reply
    debug1: Authentications that can continue: publickey
    debug2: we did not send a packet, disable method
    debug1: No more authentication methods to try.
    Permission denied (publickey).
$ssh-i~/.ssh/deploy\u rsa deploy@
... 这里跳过了一些日志。。。。
以下是客户端的SSH日志:
debug1:SSH2\u消息\u服务\u接收
debug2:key:/Users/ankit/.ssh/gcloud rsa(0x7ff1d16105e0),
debug2:key:/Users/ankit/.ssh/deploy\u rsa(0x0),显式
debug1:可以继续的身份验证:公钥
debug3:重新开始,传递了不同的列表公钥
debug3:首选公钥、键盘交互、密码
debug3:authmethod\u查找公钥
debug3:剩余首选项:键盘交互、密码
debug3:authmethod_是已启用的公钥
debug1:下一个身份验证方法:公钥
debug1:提供RSA公钥:/Users/ankit/.ssh/gcloud RSA
debug3:发送\u pubkey\u测试
debug2:我们发送了一个公钥包,等待回复
debug1:可以继续的身份验证:公钥
debug1:正在尝试私钥:/Users/ankit/.ssh/deploy\u rsa
调试3:签名和发送公钥:RSA SHA256:h+yezPKOVjeA2ZKOAN/1r1GRe2s1nyGKwG6wobm+Vh0
debug2:我们发送了一个公钥包,等待回复
debug1:可以继续的身份验证:公钥
debug2:我们没有发送数据包,请禁用方法
debug1:不再尝试验证方法。
权限被拒绝(公钥)。

客户机选择的另一个密钥来自
~/.ssh/config

我对Ansible了解不多,希望以下文档能有所帮助


顺便说一句,这也是可能的,因为防火墙设置。在非默认网络中,tcp:22在默认情况下是不允许的。

试试这个:请注意,如果您鲁莽地打开太多端口,您可能会遭受随机的internet出口费用。正如@Dagang所说,只需打开端口22(链接中3条规则中的第2条)Hi@Salmonstrikes我认为问题不在于网络。让我从主用户那里获得ssh。它仅阻止我在框中手动配置的第二个用户。这似乎是VM如何处理身份验证(sshd pam?)的问题。您是否可以检查/home/deploy/.ssh/authorized_密钥是否实际存在?我尝试在远程主机上创建一个新用户,但结果发现它的主目录甚至没有被创建。我不确定是否创建了该目录,我的脚本配置为创建一个不存在的目录。所以它现在存在。它还创建了具有正确权限和所有者的授权密钥文件。您希望该设施对VM具有多用户访问权限,这就是您想要的吗?谢谢,我熟悉使用控制台添加和删除密钥。相反,我想使用linux的授权密钥概念:因此我想创建一些具有特定授权密钥的用户。我可以通过ssh从我的主sshkey进入系统,这不是网络问题。我希望能够使用ansible(而不是通过控制台)创建更多这样的用户。您是否检查了/var/log/secure或/var/log/auth.log?我查找了/var/log/auth.log,除了:
Aug 3 20:29:42 instance-1 sshd[8011]:连接在71.198.45.230[preauth]之前关闭之外,我在失败时没有得到太多其他信息
谷歌似乎有自己的PAM模块,或者以某种方式控制ssh,限制我创建新的无密码ssh用户。在从Google控制台进行设置后,我还修改了中的授权密钥。但随后它自动切换到我从控制台设置的旧版本(谁在这么做?),如果问题是服务器端的,那么我希望auth.log中会有更多细节。您可以通过向ssh添加-v参数来检查客户端。在我的问题中添加了这些日志,这似乎是标准的publickey denied权限。