在/home/petri/.ssh/
我有我的私钥叫petri
。 当我尝试使用ssh连接到我的服务器时,它不接受我的私钥。 运行-v
得知它不是在尝试我的密钥petry
,而只是不存在的id_rsa和id_dsa:
$ssh server debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering public key: petri@office debug1: Authentications that can continue: publickey debug1: Offering public key: petri@office debug1: Authentications that can continue: publickey debug1: Offering public key: petri@office debug1: Authentications that can continue: publickey debug1: Offering public key: petri@office debug1: Authentications that can continue: publickey debug1: Trying private key: /home/petri/.ssh/id_rsa debug1: Trying private key: /home/petri/.ssh/id_dsa debug1: No more authentication methods to try. Permission denied (publickey).
奇怪的是之前的事情都很好。 无论如何,我该如何告诉SSH使用我的petri
键,并试图不存在的标准键?
注意:我的.ssh文件夹是chmod 700
,petri文件是600
,这不是问题。
两种方式:
在ssh命令中指定密钥,如“ssh -i〜/ .ssh / petri server.example.com”
创build一个.ssh / config文件,如下所示:
主机*
IdentityFile /home/petri/.ssh/petri
要获得更多选项,请根据您要执行的操作执行“man ssh_config”或“man ssh”。
尝试这个:
ssh -i /path/to/petri