AWS更换服务器密钥对
最近遇到开发离职,因此涉及到更改服务器密钥。
1.在aws后台生成并下载密钥,然后将密钥保存到自己电脑。
2.执行ssh-keygen -y,复制密钥路径,回车得到public key,例如
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQClKsfkNkuSevGj3eYhCe53pcjqP3maAhDFcvBS7O6V hz2ItxCih+PnDSUaw+WNQn/mZphTk/a/gU8jEzoOWbkM4yxyb/wB96xbiFveSFJuOp/d6RJhJOI0iBXr lsLnBItntckiJ7FbtxJMXLvvwJryDUilBMTjYtwB+QhYXUMOzce5Pjz5/i8SeJtjnV3iAoG/cQk+0FzZ qaeJAAHco+CY/5WrUBkrHmFJr6HcXkvJdWPkYQS3xqC0+FmUZofz221CBt5IMucxXPkX4rWi+z7wB3Rb BQoQzd8v7yeb7OzlPnWOyN0qFU0XA246RA8QFYiCNYwI3f05p6KLxEXAMPLE my-key-pair
3.利用以前的密钥登录服务器,将上面第二步的public key粘贴到~/.ssh/authorized_keys
或者相应登录用户的.ssh
目录(我的是/home/ubuntu/.ssh/authorized_keys)
然后将旧的public key注释或者删除。
4.然后你就可以利用新的密钥文件(.pem后缀文件)登录服务器了
例如:ssh -i "test.pem" [email protected]
- Create a new key pair using AWS EC2 console or a third party tool.
- Retrieve the public key from new key pair.
- Connect to the instance using the existing private key.
- Using text editor to open .ssh/authorized_keys, paste the public key of new key pair into the authorized_keys file.
- (Optional) Delete the public key information of the original key pair in the authorized_keys file.
相关推荐
byn 2020-11-19
Dancen 2020-10-20
guchengxinfen 2020-10-12
SirLZF 2020-10-10
evolone 2020-10-09
AWS爽 2020-09-21
wolfjin 2020-09-10
lilu 2020-09-08
frank0 2020-08-26
wl00 2020-08-26
QFYJTL 2020-08-23
JokerCch 2020-08-17
zwb 2020-08-14
bendan 2020-08-13
酌希 2020-08-04
快乐de馒头 2020-07-29
Dramer0 2020-07-09
黑夜流星 2020-06-28
swazerz 2020-06-22