How to set up automatic SSH login to AWS EC2 instance from a Mac terminal
Published in
Nov 12, 2023
After you have built an AWS EC2 instance,
you can login into it by SSH via the terminal:
ssh -i /Users/henrywu/MyDrive/98_Products/P01-Project-Alpha/03-keys/AWS_EC2_key_pair_helloworld.pem ec2-user@ec2-44-239-28-119.us-west-2.compute.amazonaws.com
Good news is that you don’t need to remember this long code every time. You can set up automatic SSH login.
Host myec2
HostName ec2-instance-public-dns-name
User ec2-instance-username
IdentityFile /path/to/your-private-key.pem
AddKeysToAgent yes
UseKeychain yes
ForwardAgent no