CentOS下使用密钥登录
1.使用ssh-keygen命令生成密钥对
[root@localhost ~]# ssh-keygen
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:
SHA256:AnQLEK8mAe5DPClhIn9NXs/LihsETuqjoNQcwQp6OGo root@localhost.localdomain
The key's randomart image is:
+---[RSA 2048]----+
|= +=. |
|oo+..o |
|.o+o=. |
| =o=.+. . |
|..O + ES |
| * * o |
|o & = o |
|.*.@ o |
|..*=o |
+----[SHA256]-----+

生成的密钥在用户目录下的”.ssh”目录中
id_rsa是私钥
id_rsa.pub是公钥

2.在服务器上安装公钥
[root@localhost ~]$ cd .ssh
[root@localhost .ssh]$ cat id_rsa.pub >> authorized_keys
3.下载私钥

1.使用xftp连接下载

2.如果用的Xshell还可以用lrzsz命令下载

[root@localhost ~]# yum install -y lrzsz
[root@localhost ~]# sz id_rsa
4.修改ssh配置文件
[root@localhost ~]# vim /etc/ssh/sshd_config

找到几个选项修改成如下(密码登录可不禁止)

 

#禁止使用密码登录
PasswordAuthentication no

#允许root认证登录
PermitRootLogin yes

#允许密钥认证
PubkeyAuthentication yes

保存

 

5.重启ssh
[root@localhost ~]# service sshd restart

最后将登录方式改为密钥登陆

 

 

 

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇