E.G*_*.G. 14
在你的电脑
cd ~/.ssh
ssh-keygen -t dsa
Run Code Online (Sandbox Code Playgroud)
在每个提示符下按Enter键
Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_dsa.
Your public key has been saved in /home/user/.ssh/id_dsa.pub.
The key fingerprint is:
ad:98:43:13:c9:ea:66:8e:d0:d9:66:59:d8:3a:f7:29
The key's randomart image is:
+--[ DSA 1024]----+
| |
| . . |
| + |
| + . . |
| o = S . |
| . + = + . |
|. o @ = . |
| . B oEo . |
| . . .o |
+-----------------+
Run Code Online (Sandbox Code Playgroud)
您将获得2个文件,id_dsa并id_dsa.pub使用scp或其他实用程序将文件复制到您的服务器
scp ~/.ssh/id_dsa.pub user@host:~/.ssh/
Run Code Online (Sandbox Code Playgroud)
在您的服务器上
将新密钥添加到文件〜/ .ssh/authorized_keys.
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
Run Code Online (Sandbox Code Playgroud)
最后改变访问模式;
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
Run Code Online (Sandbox Code Playgroud)
验证〜的访问模式是否正确
ls -ld ~
Run Code Online (Sandbox Code Playgroud)
如果没有,你可以使用
chmod 700 ~
Run Code Online (Sandbox Code Playgroud)
纠正您的家庭访问.
注销并再次登录
小智 10
键入以下命令
ssh-keygen
按Enter键直到出现提示
ssh-copy-id -i root@ip_address
(它会一次询问主机系统的密码)
ssh root@ip_address
现在您应该可以在没有任何密码的情况下登录