使用公私钥进入远程服务器

我最近在两台linux机器上设置了ssh(让我们称它们为server-a,client-b)。 我已经在客户机上使用ssh key gen生成了两个ssh auth文件,并且可以在.ssh目录中看到公共和私有文件。 我已经将它们命名为“example”和“example.pub”。

然后我添加了example.pub到sever-a的auth文件。 当我尝试SSH入服务器 – 它仍然要求进行密码身份validation,因为我想要一个密码lesslogin(客户端上的私钥设置没有密码)。

当我尝试用'-v'ssh获取以下输出:

debug1: Next authentication method: publickey debug1: Trying private key: /Users/abc/.ssh/identity debug1: Offering public key: /Users/abc/.ssh/id_rsa debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,keyboard-interactive debug1: Offering public key: /Users/abc/.ssh/id_dsa debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,keyboard-interactive debug2: we did not send a packet, disable method debug1: Next authentication method: keyboard-interactive debug2: userauth_kbdint debug2: we sent a keyboard-interactive packet, wait for reply debug2: input_userauth_info_req debug2: input_userauth_info_req: num_prompts 1 Password: 

请帮忙。

您也可以使用'ssh-copy-id'将公钥上传到服务器。

语法是:

 ssh-copy-id [-i [identity_file]] [user@]machine 

如果这不起作用,回应Trevor的问题。

Pubkeyauthentication可能会有点烦人。 授权密钥文件的默认位置是〜/ .ssh / authorized_keys,而且密钥必须是单行格式(一行中的所有内容,对于我来说,如果它曾经超过1行格式,那么您几乎可以放弃所有的希望,在那个工作)。

此外,愚蠢的想法,但你可以确保位置.ssh / authorized_keys被设置为公共密钥的默认位置的主要价值。

也可以检查服务器上的日志文件,看看有没有什么好的信息。