1 個回答
- 最新
- 最多得票
- 最多評論
1
- Use SSH Agent to Manage Your Keys If you haven't already, start the SSH agent in the background and add your existing private key (the one you currently use to access your EC2 instance) to the agent. This step is necessary to facilitate password-less login via the SSH protocol.
eval $(ssh-agent -s)
ssh-add /path/to/your_existing_private_key
Replace /path/to/your_existing_private_key with the actual path to your private key file.
- Use ssh-copy-id to Copy the New Public Key Now, you can use ssh-copy-id to copy the new public key to your EC2 instance. Specify the -i option with the path to the new public key you wish to copy.
ssh-copy-id -i /path/to/new_public_key.pub ec2-user@your-ec2-public-dns
Replace /path/to/new_public_key.pub with the path to your new public key file and your-ec2-public-dns with the public DNS or IP address of your EC2 instance. The default user name for Amazon Linux instances is ec2-user, but this may vary depending on the AMI used (for example, ubuntu for Ubuntu AMIs).
相關內容
- AWS 官方已更新 1 年前
please accept the answer if it was useful for you