-
Notifications
You must be signed in to change notification settings - Fork 2
SSH
SSH is a protocol for logging into remote systems and is used exclusively for access to ACAD servers. If you are on a Mac, you already have SSH installed and can access it from a Terminal
. The following information applies to Mac or Linux users. For windows users, please install PuTTY and alter the instructions as appropriate.
Open a Terminal
. You will see a prompt in the terminal, likely containing your username and workstation name, followed by a dollar symbol ($). Using the ssh
command, specify your university username and the hostname of the target server. You will be prompted for your university password. In the example sessions below, commands to be typed are shown in bold to distinguish them from other text appearing in the terminal.
grg@IonTorrent:~$ ssh a1158147@acad2.rc.adelaide.edu.au ***************************************************************************** ************************The University Of Adelaide*************************** *******************************SECURED LOGIN********************************* ***************************************************************************** Use of this system is restricted to authorised users only. Without such permission, your access is UNAUTHORISED and you are committing a criminal offence under Australian law. Under the Federal Cybercrime Act 2001 (Cth), Schedule 1, Part 10.7 - Computer Offences, Division 477 (as amended) it is an offence to: (i) Obtain unauthorised access to data held in a computer; or (ii) Cause unauthorised modification of data held in a computer; or (iii) Cause unauthorised impairment of electronic communications to or from a computer These offences are punishable by imprisonment for life or a period of 5 or more years. The University of Adelaide logs all activities and login attempts on this equipment, including but not exclusively the IP address and keystrokes that are made on this console. The University of Adelaide will liaise with law enforcement officials to prosecute any individuals that unlawfully access this system. ***************************************************************************** ***************************************************************************** a2158147@acad2.rc.adelaide.edu.au's password: **PASSWORD** Last login: Never logged on Kickstarted on 2015-02-12 [a1158147@acad2 ~]$
You can logout from the server at any time by typing exit
. Alternatively, you can send the End Of File (EOF) character to the shell by typing CTRL-d
(press 'd' while holding the control key).
In documentation, it is common to represent prompts with a singular dollar symbol ($), omitting the username and hostname. When it is clear to do so, we will follow this same convention.
Using SSH keys will allow you to login to a remote system without typing a password each time. On your workstation, open a Terminal
and type ssh-keygen
. Just press ENTER
at passphrase prompts, until the program completes. You have now created a pair of keys on your workstation. This pair of keys are linked to each other, and are known as public and private keys. You will retain the private key on your workstation and the public key will be copied into a specific directory on the server. Follow the directions below to copy the private key and place it in the correct location on the server.
grg@IonTorrent:~$ ssh-copy-id a1158147@acad2.rc.adelaide.edu.au ...
Now attempt to login again. You should not receive a password prompt. Please do not share your private key, as anyone with this file will be able to logon to the server as your user. To enjoy the same effect when loging on to each server, you need not create a new key pair, just copy your public key to the .ssh
directory on the relevant server.
Troubleshooting: A common problem with logging in using ssh keys relates to the permissions on the various files. In particular, the .ssh
directories (on both server and workstation) should be only accessible by your user (run chmod 0700 $HOME/.ssh
to correct this). Likewise, the id_rsa
file on your workstation, and the authorized_keys
file on the server should only be accessible by your user (run chmod 0600 $HOME/.ssh/authorized_keys
on the server and chmod 0600 $HOME/.ssh/id_rsa
on your workstation). For other problems, try running ssh in verbose mode (e.g. ssh -vvv a1158147@acad2.rc.adelaide.edu.au
).
So now you can logon without a password, but you still need to remember the hostname and type in your tediously long username. These are newbie problems and we don't have to stand for that! On your workstation, you will need to edit the ssh config file for your user. You can find the location of this file by opening a Terminal
and typing echo $HOME/.ssh/config
. Edit (or create) this file so that it contains the following (appropriately changed for your username and relevant server hostname):
Host acad2 User a1158147 HostName acad2.rc.adelaide.edu.au ServerAliveInterval 60
You may add additional entries for other hosts. The ServerAliveInterval 60
directive maintains the ssh connection by sending a keep alive signal every 60 seconds, that will prevent your connection from timing out due to lack of activity. See the ssh_config
manual page for more options (type man ssh_config
in your Terminal). Now you can logon like so:
$ ssh acad2
Files can be transferred to or from a server using the scp
command. Because scp
uses the SSH
protocol for authentication, the configuration shown above for logging in also applies when using scp
. All commands shown below are run from your workstation, not the server.
Copy a single file from the current directory on your workstation to your home directory on the ACAD2 server.
$ scp testfile.txt acad2: ... testfile.txt 100% 0 0.0KB/s 00:00
Copy a directory from your workstation to a specific location on the server, using absolute paths. Note the addition of the -r
parameter is required to recursively copy directories.
$ scp -r /path/to/some/stuff acad2:/localscratch/mydir/ ...
Copy a directory from the server to the current directory on your workstation.
$ scp -r acad2:/localscratch/mydir/bison_plots . ...