本文主要是介绍SSH通过密钥登入.md,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
- 在服务端生成密钥对:
ssh-keygen -t rsa
[root@twx ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
2d:34:ba:cc:f1:1e:8b:80:56:1e:6f:9d:37:8f:64:8d root@twx
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| o |
| o o |
| o o S . |
| + = = o o |
| o o * = E . |
| . o o * + |
| . o . . |
+-----------------+
生成的密钥对在/root/.ssh/文件夹下。
- 将公钥文件输出到 一个特定的文件里(见步骤3里的文件名):
cat id_rsa.pub > authorized_keys
-rw------- 1 root root 390 Jul 25 04:38 authorized_keys
-rw------- 1 root root 1675 Jul 25 04:37 id_rsa
-rw-r--r-- 1 root root 390 Jul 25 04:37 id_rsa.pub
- 修改文件权限
chmod 600 authorized_keys
chmod 700 ~/.ssh
- 修改ssh配置文件:
vim /etc/ssh/sshd_config
修改下面三行
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys #(注意这个文件名)
退出保存
- 重启ssh服务:
service sshd restart
-------至此,服务端已经配置好了-------------------
putty
- 通过ftp工具把/root/.ssh/id_rsa文件下载到本地
- 打开puttygen.exe,点击Load,选择id_rsa,然后另存为putty格式的密钥
- 打开putty,点击SSH-Auth–选择加载private key
这篇关于SSH通过密钥登入.md的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!