SSH 登录无需重新检查所有公钥

SSH 登录无需重新检查所有公钥

我有多个服务器和不同的用户。此外,我还有两种不同的授权方法:通过密钥和密码。

当我尝试登录 ssh 时,请重新检查所有公钥。有没有方法可以绑定公钥和服务器?

详细信息如下:

ssh -v root@serv

debug1: Offering RSA public key: /home/user/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: user1@web3
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: user2@web2
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: root@web1
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: user3@web3

答案1

您可以使用〜/.ssh /配置文件并将每个主机的配置详细信息放入其中

Host serv1
    hostname serv1.example.com
    user serv1user
    IdentityFile ~/.ssh/serv1user.key

Host serv2
    hostname serv2.example.com
    user root
    IdentityFile ~/.ssh/rootserv2.key

Host serv3
    user root
    IdentityFile ~/.ssh/rootserv3.key

现在您可以ssh serv1执行等操作,并从配置文件中提取相关详细信息。

相关内容