SSH AWS EC2 by your account with keypair without specify pem file

Assume you have the keypair file generated by AWS console

In your local machine and your account
> cat ~/.ssh/id_rsa.pub
# Copy the output

> ssh -i /path_to_key_pair/my-key-pair.pem ubuntu@your-ec2-ip-or-domain

In AWS EC2
ubuntu> sudo su your-account
# If you still don't have user account, create one by this instruction
# https://aws.amazon.com/premiumsupport/knowledge-center/new-user-accounts-linux-instance/

your-account>echo [The id_rsa.pub content you just copy] >> ~/.ssh/authorized_keys
your-account>exit
ubuntu>exit

In your local machine, connect to ec2 by
>ssh your-account@your-ec2-ip-or-domain

Voila



留言

熱門文章