Using SSH on Unix

Using ssh on a Unix is a trivial task. If you are familiar with Telnet or RSH, then you'll find SSH is very similiar:

To SSH from one Unix system to another:

  • ssh username@system

    For example:,

    (user@borg)[$:~] ssh sz@chase.mathstat.dal.ca
    sz@chase.mathstat.dal.ca's password:

    After entering my password, I'm now logged into the chase system.

    Transferring Files using SCP on Unix

  • scp username@system:/path/to/file/on/remote/system /location/of/file/on/local/system

    For example:

    (sz@jupiter)[$:~] scp sz@dhcp:.bash_history .
    sz@dhcp's password:
    .bash_history 100% |*****************************| 1257 00:00

    The above copies the file .bash_profile from my account on the machine 'dhcp' to the account i'm running the 'scp' process from.

    To copy an entire directory from the machine 'dhcp' to the local machine, I would use scp's -r option:

    (sz@jupiter)[$:~] scp -r sz@dhcp:example .
    sz@dhcp's password:
    dhcpd.conf 100% |*****************************| 3351 00:00

    In this example, I am transferring the directory named 'example' from machine 'dhcp' to the local system'.

    Note: the dot ('.') in the examples I'm using: this instructs scp to place the files in the current working directory; the directory you're running the scp process from. Replace the '.' with the path to the directory you want your files copied to. e.g.,

    scp sz@remotesystem:example /home/sz/newfiles

    The above would copy the directory 'example' frmo machine 'remotesystem' to the local directory /home/sz/newfiles. Ensure that the local directory exists before attempting to transfer files to it!

    Note 2: In all examples, the ':' (scp sz@chase:somefile /tmp) is imperative; without it scp will assume you want to copy files locally (just like using cp), and not to a remote machine!