Norwegian version of this page

SSH howto

Secure shell (SSH) is both a program and a network protocol that is located at the application layer and is normally used to access the command line (shell) on another computer.

Mac

Apple’s OS X is an UNIX-like operating system, similar to Linux, therefore it’s easy to log in to IFI’s Linux servers through OS X’s built-in terminal. To be able to open programs with graphical user interfaces in new windows in addition to using text commands in the terminal, you need a program called X11, also called X Windows System. In simple terms it’s a program for running GUI programs over networks. While the earlier versions of OS X included X11, it is no longer included in OS X 10.8 (Mountain Lion). If you have OS X 10.8 or newer (and you should if you keep your system updated), go to http://xquartz.macosforge.org and download the .dmg file under “Quick Download”. Open the file to install X11.

To log in, first open a terminal window. You can find the terminal program by searching for “terminal” in the search tool in the menu bar on the top right. Then type the following command, and replace the username with your UIO username (~$ is the prompt, so just enter what comes after):

~$ ssh -YC username@login.ifi.uio.no

If you only want to work in the terminal and do not need to open GUI windows, you can drop the -YC option. You will then be asked for a password. Caution: It may not seem like you are typing anything, but it’s just because the number of characters is hidden for security reasons. After confirming the password, given that it was correct, you will be logged in to the UIO computer. See here for some tips for working with Linux through a terminal.

In case you want to avoid typing the entire command every time you log in, you can create an alias, so that you can instead just type “uio” for instance. To do just that enter the line

alias sshuio='ssh -YC username@login.ifi.uio.no'

(replace “username” with your UIO username) in the .bash_profile file in the home directory on your pc and start a new terminal. You need to create this file if it doesn’t exist yet, see https://redfinsolutions.com/blog/creating-bashprofile-your-mac/

SCP in Mac

See SCP in Linux.

Linux

You can log in remotely with a simple command. In the  terminal window enter the following (~$ is the prompt, replace “username” with your UIO username):

~ $ ssh -YC username@login.ifi.uio.no

You will then be asked for a password. Caution: It may not seem like you are typing anything, but it’s just because the number of characters is hidden for security reasons. After confirming the password, given that it was correct, you will be logged in to the UIO computer.

You can use aliases to avoid tying long commands. Add for instance

alias sshuio='ssh -YC username@login.ifi.uio.no'

in the .bashrc-file in your home directory (replace “username” with your UIO username). Then you can just type “sshuio” in the terminal instead of the entire line above.

Installation of the home directory with SSHFS

See https://www.uio.no/tjenester/it/lagring-samarbeid/hjemmeomrader/hjemmeomrade/linux/SSHFS/ for guidelines on how to mount your UIO home directory an thus gain access to the UIO files as if they were local files on their own hard drive. See also what is written about aliases above. Alias for sshfs:

alias uiofiles='sshfs <username>@login.uio.no: ~/uio -o reconnect,modules=iconv,from_code=utf8'

SCP in Linux

To transfer files between the UIO and your local computer, scp (secure copy) is used. You navigate to the folder where you have the file you want to upload to UIO and copy it over with the command below. For instance, if the file is called “assignment1.pdf” that you want to upload to the folder “IN1000” in your home directory, the command (where you naturally replace “username” with your UIO username):

~$ scp assignment1.pdf username@login.ifi.uio.no:~/IN1000/

You will be asked for your UIO password.

If, instead, you want to download a file, eg. “assignment1.pdf” from the “IN1000” folder, the command will be:

~$ scp username@login.ifi.uio.no:~/IN1000/assignment1.pdf ~/

This command places the file directly in the home directory specified in the second argument (~/), but you can also enter the folder you want as follows:

~$ scp username@login.ifi.uio.no:~/IN1000/assignment1.pdf ~/UIO/courses/IN1000/

For more information regarding use of scp read the manual, which can be accessed with:

~$ man scp

(which can be closed with “q”).

 

Published Mar. 26, 2021 12:35 PM - Last modified Apr. 6, 2021 5:06 PM