尝试这个...

尝试这个...

是否可以将密码添加到 ssh 配置中,以便每次登录远程主机时不再输入密码?

答案1

尝试这个...

使用默认值(不带密码)...这将为您提供无密码 SSH。这对于安全性良好或可能在家庭环境中的系统来说是理想的选择。如果输入密码,则可以通过在 gui 会话的负载上生成 ssh-add 来使用 ssh-agent。这将使用单个密码管理您的密钥环,甚至对于您使用 ssh 密钥使用的密码,当您 ssh 到已推送 SSH 密钥的客户端时,系统将不再提示您输入它们。

这是基于密钥的身份验证...比仅将密码弹出到文件中更安全。

[fedodora@server ~]$ ssh-keygen -t rsa
[fedodora@server ~]$ ssh-copy-id -i .ssh/id_rsa.pub fedodora@newserver
The authenticity of host 'newserver (X.X.X.X)' can't be established.
RSA key fingerprint is ab:cd:ef:12:34:56:78:90:1f:4d:d9:ff:2e:5f:97:8d.
Are you sure you want to continue connecting (yes/no)? yes
fedodora@newserver's password: {enter your remote server user's password here}
Warning: Permanently added 'newserver,X.X.X.X' (RSA) to the list of known hosts.  
Now try logging into the machine, with "ssh 'fedodora@newserver'", and check in:

   .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

您可以使用 -v 验证 SSH 的调试输出,以查看是否尝试了多种身份验证机制。这被称为 SSH 的公钥。

[fedodora@server ~]$ ssh -v newserver

在 SSH 会话连接之前,您应该会得到这样的尾随输出。

debug1: Next authentication method: publickey
debug1: Trying private key: /home/fedodora/.ssh/identity
debug1: Offering public key: /home/fedodora/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Day Month Date HH:MM:SS YYYY from X.X.X.X

相关内容