one line access to aws ec2

If you use pem file to access to remote ec2 address, usually it’s like below

ssh -i ubuntu.pem ubuntu@ip_address

But how to access the remote ec2 using just one line? For example, use sftp, ssh, scp command. You can achieve that by the following:

cat ~/.ssh/id_rsa.pub | ssh -i aws.pem ubuntu@ip_address “cat – >> ~/.ssh/authorized_keys”

Leave a Reply

Your email address will not be published. Required fields are marked *