Using SSH/SCP on Mac OS X in the Terminal app

For those of you using Mac laptops, Mac OS X comes with everything you need.

Using SSH on Mac OS X in Terminal

First, find ‘’ (you can use Spotlight to search for ‘Terminal app’, or you can look in your Applications, Utilities folder.)

Double-click on it.

You should now see a window with something like this:

...-macbook:~ Guest$

in it. This is called ‘the shell prompt’, or the ‘command-line interface’, and it’s a low-level way to interact with the computer. You can do all sorts of neat things here (including open applications, edit and delete files, write programs, etc.) but mostly we’re going to use it to connect to the same kind of prompt, but on a remote computer.

(Note that you can customize the font size, color, etc. of the Terminal window to your liking. I’m old and hard of eyesight, so I like to make the font big: you can do that with command-shift-+.)

From this point on, everything that follows the ‘%%’ and is in teletype font is something for you to type at a command line prompt.

So, to start, type

%% ssh -i $keyfile root@$amazon

replacing ‘$keyfile’ with the location of your key file, and ‘$amazon’ with the hostname of your amazon machine.

The first time you do this on any computer, it will say something like “the computer <some long name> is unknown to us; do you really want to connect?” – say “yes”.

Now you should see a login banner followed by the prompt ‘... # ‘.

Now you can go back to the UNIX, ssh, and scp tutorial, or continue on to Transferring files with SCP.

Transferring files with SCP

Create a file on your local computer: in Terminal, at the shell prompt, type:

%% echo hello, world > a-file.txt

Now copy this file to the directory on the remote computer:

%% scp -i $keyfile a-file.txt root@$amazon:

where you should again replace $keyfile and $amazon with your key filename and your amazon machine name, respectively.

‘scp’ will ask for a password. Give the same super-secret password we gave you in class.

Note that you can also transfer files from remote machines to your local machine:

%% scp -i $keyfile root@$amazon:a-file.txt local-file.txt

More generally, the scp command will copy a local file to a remote location:

%% scp <local file> <remote user>@<remote machine>:<remote path>

or vice versa, a remote file to a local file:

%% scp <remote user>@<remote machine>:<remote path> <local file>

LICENSE: This documentation and all textual/graphic site content is licensed under the Creative Commons - 0 License (CC0) -- fork @ github. Presentations (PPT/PDF) and PDFs are the property of their respective owners and are under the terms indicated within the presentation.
comments powered by Disqus