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
当我尝试在“DDEV auth ssh”之后的DDEV web容器中使用ssh时,ssh密钥不';“这似乎不起作用。”;身份验证失败太多”;_Ssh_Ddev - Fatal编程技术网

当我尝试在“DDEV auth ssh”之后的DDEV web容器中使用ssh时,ssh密钥不';“这似乎不起作用。”;身份验证失败太多”;

当我尝试在“DDEV auth ssh”之后的DDEV web容器中使用ssh时,ssh密钥不';“这似乎不起作用。”;身份验证失败太多”;,ssh,ddev,Ssh,Ddev,我已经使用ddev auth ssh将我的ssh标识添加到我的ddev本地项目中 但是,当我使用ssh连接到外部主机时,ssh example.com会出现“太多身份验证失败” 当我使用ssh-v example.com时,我看到它在放弃“太多身份验证失败”之前尝试了六个不同的密钥: 我怎样才能解决这个问题?请注意,我的~/.ssh目录中有10个不同的私钥。看来ssh并不是为私钥的加载而设计的,但有些人最终还是会得到很多私钥。(请注意,您可以将单个私钥用于多种用途;您与世界或外部服务共享的全部是

我已经使用
ddev auth ssh
将我的ssh标识添加到我的ddev本地项目中

但是,当我使用ssh连接到外部主机时,
ssh example.com
会出现“太多身份验证失败”

当我使用
ssh-v example.com
时,我看到它在放弃“太多身份验证失败”之前尝试了六个不同的密钥:


我怎样才能解决这个问题?请注意,我的~/.ssh目录中有10个不同的私钥。

看来ssh并不是为私钥的加载而设计的,但有些人最终还是会得到很多私钥。(请注意,您可以将单个私钥用于多种用途;您与世界或外部服务共享的全部是公钥,它不会泄露任何有关私钥的信息。)

由于
ddev auth ssh
正在为您设置ssh代理,而且似乎没有办法让ssh从代理提供的标识中选择特定标识,因此您需要使用两种解决方法之一

解决方法1:只需使用几个键 当然,您可以将~/.ssh目录中的密钥数减少到6或更少(6是服务器端sshd中
maxauthries
的默认值)。但我们假设你不想这么做

创建一个目录,可能是
~/ddev ssh-keys
。在该目录中,复制或符号链接您最常用的6个键。所以对于goodkey1 goodkey2中的项,
cd~/ddev ssh密钥&&。。。googdkey6;do ln-s~/.ssh/$item;完成
(或以任何方式完成链接或复制)

现在,ddev auth ssh-d~/ddev ssh密钥和ddev ssh代理将仅具有这6个密钥。如果它们是解决大多数问题的正确关键,那么您应该善于使用这种方法

解决方法2:使用.ddev/homeadditions将密钥复制到容器中 此解决方法将允许您将所需的密钥实际复制到web容器中。这可能不像第一种方法那样安全(因为您永远不应该真正地将私钥复制到任何地方),但它可以工作

如果您确实希望将密钥放在容器中(而不是使用代理),那么
mkdir-p.ddev/homeadditions/.ssh&&cp~/.ssh/.ddev/homeadditions/.ssh&&chmod 700.ddev/homeadditions/.ssh&&chmod 600.ddev/homeadditions/.ssh/*
。然后,您可以以任何方式使用.ddev/homeadditions/.ssh/config文件,包括指定密钥

这个答案改编自

Received disconnect from 174.127.116.22 port 22:2: Too many authentication failures
Disconnected from 174.127.116.22 port 22
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: rfay@rfay-mbp-2017.local RSA SHA256:LrokWMbl1bD0vV0z7Qpn4HLd168NYSIAbqsek6aXIaE agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: rfay@rfay-mbp-2017.local RSA SHA256:ecpRhfcaRWS8EfmYyLuJ81ayhyPWAZd9MG3mKOUKMqA agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: rfay@rfay-mbp-2017.local RSA SHA256:07LrVlDSWu4r+4Eb6WP8FpWYYcREw7IcGm4rtp5v+Ws agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: rfay@rfay-mbp-2017.local RSA SHA256:6L9cIsLlu858CPgb5zZ3v3+5p808uNencyAxJ0S9wOM agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: rfay@rfay-mbp-2017.local RSA SHA256:HwksLkZqEXAK6Zo21+y/C508Mjx2I7EvUQWFScKHsAQ agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: rfay@rfay-mbp-2017.local RSA SHA256:dsGaELF0OPNyQfIYZoEyI+dP3AQqh5r+15iUwfalNtc agent
Received disconnect from 174.127.116.75 port 22:2: Too many authentication failures
Disconnected from 174.127.116.75 port 22