AWS更换密钥

最近遇到开发离职,因此涉及到更改服务器密钥。

1.在aws后台生成并下载密钥,然后将密钥保存到自己电脑。

2.执行ssh-keygen -y,复制密钥路径,回车得到public key,例如

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCMAS8mviirg23XvhyGzydp0VlP/fyfuhsHKMECZydc5ewytvTq0mqYTfjKBS++PeBpEL1Zx/ilEYCmgY6omTrIMtG8s1jf/lAk0l9++f2ldp/w2U86seARyRxVEePU7YCnbofqgtGJJDASDHNiEbshXQ6M49nUsE6tfETG3sFl+XDeva0lkNkssA4JDU+eivPRGma3XcBAXvsUsD8VkKQJvudrpJDSjjncdjYOVd2Wcrcj5Li8MmLvIkEX1pmqTT6O6oUfEtCdpVi4tCwTXV5ydU8UtjJDSGDFSJgbY9Unve4LgjgoWF677FdUpvVFD1NPoLH

3.利用以前的密钥登录服务器,将上面第二步的public key粘贴到~/.ssh/authorized_keys
或者相应登录用户的.ssh目录(我的是/home/ubuntu/.ssh/authorized_keys)
然后将旧的public key注释或者删除。

4.然后你就可以利用新的密钥文件(.pem后缀文件)登录服务器了
例如:ssh -i "test.pem" ubuntu@192.168.1.1

  1. Create a new key pair using AWS EC2 console or a third party tool.
  2. Retrieve the public key from new key pair.
  3. Connect to the instance using the existing private key.
  4. Using text editor to open .ssh/authorized_keys, paste the public key of new key pair into the authorized_keys file.
  5. (Optional) Delete the public key information of the original key pair in the authorized_keys file.

参照:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#replacing-key-pair
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#retrieving-the-public-key

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值