Development
Connecting to an Amazon Server from a Mac Using the Terminal
How to connect via SSH using the terminal
- I’m posting this to organize and record what I learned while struggling through this early on.
- What you’ll need:
- Install putty
- A .ppk file or a .pem file (on a Mac you need to convert the .ppk file to a .pem file - described below)
- The IP information of the server you want to access.
Getting Started
- Install putty in the Terminal using homebrew
$ brew install puttyIf brew is not installed, install brew first and then install putty
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"- Use puttygen to convert the .ppk file extension to .pem
$ puttygen [file name].ppk -O private-openssh -o [file name].pem- Then register the converted key file. Various guides recommend setting it to 400, 500, 600, or 700, but in my case it worked when I set it to 700
$ chmod 700 [fime name].pem- Once you’ve done this, the converted file is created in that folder, and you use it to connect to aws via ssh.
$ ssh -i [file name].pem ubuntu@ip-address- A few steps for exiting with exit or opening a new terminal to upload files
Transferring a single file
$ scp -i [pem file name] [name of file to upload] [user id]@[ip-address]:~/
$ scp -i example.pem example.py ubuntu@100.1.1.1:~/Transferring an entire folder
$ scp -i [pem file name] -r [name of folder to upload] [user id]@[ip-address]:~/
$ scp -i example.pem example ubuntu@100.1.1.1:~/