aws Linux操作系统修改秘钥用户

解决方案:

1. 先创建用户,参考如下命令

# useradd test

2. 切换到新用户:

# sudo su - test

3. 在新用户中用命令ssh-keygen生成密钥。

$ ssh-keygen

Generating public/private rsa key pair.

Enter file in which to save the key (/home/test/.ssh/id_rsa):

Created directory '/home/test/.ssh'.

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/test/.ssh/id_rsa.

Your public key has been saved in /home/test/.ssh/id_rsa.pub.

The key fingerprint is:

8d:d2:8f:5e:b8:9d:2e:69:59:1a:b6:a8:1f:ed:b8:ae test@jacobliu2018

The key's randomart image is:

+--[ RSA 2048]----+

|                 |

|                 |

|                 |

|       . o       |

|      . S .      |

|       oo+.      |

|      .o+Bo      |

|      .=B+ .     |

|    E==o+o+      |

+-----------------+

4. 键入以下命令,在服务器上安装公钥并修改文件authorized_keys权限为只有本用户可以读写:

$ cd .ssh

$ cat id_rsa.pub >> authorized_keys

$ chmod 600 authorized_keys

5. 将文件id_rsa拷贝出来到windows主机,参考如下步骤:

a. 切换到root 用户: sudo su -

b. 复制到ec2-user用户目录下: cp /home/test/.ssh/id_rsa /home/ec2-user/

c. 增加文件/home/ec2-user/.ssh/id_rsa的其他用户读写权限: chmod +r /home/ec2-user/.ssh/id_rsa

d. 通过winscp将文件/home/ec2-user/.ssh/id_rsa拷贝windows主机

e. 在windows主机中将文件id_rsa转化为putty支持的格式。

f. 之后就可以用putty加密钥登陆linux主机了。

猜你喜欢

转载自blog.csdn.net/qq_39579242/article/details/81775997
AWS
今日推荐