Monday, July 4, 2011

How to ssh into Amazon EC2 Linux instance (and copy stuff over)

This is easy enough on an absolute scale but can be a bit of a nightmare if you're windows-oriented (as I unfortunately am ... but I am trying to snap out of it).

Here's a list of steps:
  • Create amazon instance with a new key pair
  • Save your private key to a known location (it's a .pem file you'll download in the process)
  • Make sure the folder with the private key has appropriate access otherwise it won't work (e.g. on mac: chmod -R 700 path/to/pvtk).
  • In the EC2 dashboard go the the security group settings for the instance and open ssh port 22
  • Connect: ssh -i path/to/key/myKey.pem root@my-ec2-public-ip.amazonaws.com 

An alternative to referencing your key on the ssh command is to add it via ssh-add (on mac).

Another thing you might wanna do is to copy stuff over to the EC2 instance - you can use the scp command:

scp test/winning.txt root@my-ec2-public-ip.amazonaws.com:temp-files/

Good luck!

15 comments:

Brant said...

thanks dude it worked for me, I made 10 lunux severs and was able to log in via ssh using your directions. the ssh p keys is downloaded from the console.

Unknown said...

Glad to help - it took me a while to figure that stuff out :)

Anonymous said...

thanks a lot dude.

the neezyness said...

Wow, thank you sir!

edubecks said...

Thanks! It worked for me

mukpin said...

thanks i need it most..

Ege said...

thank you!

Ardee Aram said...

Got in successfully via my client's AWS using your instruction. Thanks!

Anonymous said...

Just gotta say it again. THANKS!

Anonymous said...

thanks worked for me.

Anonymous said...

Worked for me too. Many thanks.

Vinil said...

Thankso mucho....I workso :-)

ameyk said...

Thanks Johnny..helped me a lot

ameyk said...

Thanks Johnny..helped me a lot

Anonymous said...

Thousand other posts out there..nothing worked..This one did..! Thanks for very clear instructions.