本站文章总数为:165
Search Posts

Linux生成ssh公私钥 并开启ssh key登录

内容纲要

linux生成ssh公私钥

 文件/etc/ssh/sshd_config 里面如下配置注释去掉
PasswordAuthentication yes

AuthorizedKeysFile      .ssh/authorized_keys

[root@s18vn-gmt-new ~]# vim /etc/ssh/sshd_config
[root@s18vn-gmt-new ~]# 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:
SHA256:2f/1LdKJaIOST6VxFhhtTzGodSZj+S91UP2CuIKIr6A root@s18vn-gmt-new
The key’s randomart image is:
+—[RSA 2048]—-+
|        .. oo. .o|
|         oX +.. .|
|        .=.X . ..|
|        .o..+ o o|
|   . . .S =. o o |
|  . . . .*… .  |
|.  .   .oo ..+ ..|
|..  . o.. + o.+.o|
|E ..   o.. . …o|
+—-[SHA256]—–+
[root@s18vn-gmt-new ~]# cd .ssh/
[root@s18vn-gmt-new .ssh]# ls
id_rsa  id_rsa.pub

[root@s18vn-gmt-new .ssh]# cat id_rsa.pub >> authorized_keys

[root@s18vn-gmt-new .ssh]# service sshd restart

其中id_rsa下载或者cat 命令查看复制到本地创建文件 ,进行远程

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注