Remote connection to tolab¶
Commands¶
The ssh (Secure SHell) and the scp (Secure copy) commands are used to establish a protected remote connection between your computer and a host, and exchange files between the two systems. Your tolab account (with all the files you create, modify and use during the lab sessions) is hosted at tolab.fisica.unimi.it.
Using ssh, you can connect to it from your computer, and access all the files as if you were physically in the lab; using scp, you can exchange files and directories from your computer's file system and the tolab ones (e.g. you can download the exercises you were working on during class, finish them on your computer while you're home and then re-send them to the tolab machine). To do so, use the following commands:
cp, with the difference that either [source] or [destination] are remote files/directories (for directories, remember to add -r option).
Example¶
Mario Rossi wants to work, from home, on the exercises he started during lab. He can do it in two ways:
First way (not recommended):¶
He connects to tolab with the command: ssh mario.rossi@tolab.fisica.unimi.it Now, he enters his password and then can access all the files he worked on.
Second way (recommended):¶
He knows that the directory he's interested is "~/Documents/Info/Lab3". He then types the command:
The broken down syntax is:
scp: the command for Secure Copy.-r: option for directories.mario.rossi@tolab.fisica.unimi.it:~/Documents/Info/Lab3
[source] directory. before the ":" is the hostname, together with the username, while after is the directory path starting from the home directory of the mario.rossi user on the host..[destination] directory.
He then enters the password and all objects in "~/Documents/Info/Lab3" directory will be copied into a directory named Lab3 inside the current directory.
For the curious reader: setting up an alias for the hostname¶
Having to type down [username]@tolab.fisica.unimi.it anytime is a tedious and repetitive task. Wouldn't it be easier if we could just type
and enter the password?
It is possible by changing the configuration file of ssh.
First, go to your home directory with cd and then go to .ssh directory with cd .ssh. It is a hidden directory, so you might have never noticed it, but it's there.
If it doesn't exist, create a config file with touch config, and open it with your favourite editor. In the config file, write:
[alias] could be anything you want, such as "Info", "tolab", "fisica" or whatever. From now on, you can use [alias] anywhere you would have to use [username]@tolab.fisica.unimi.it. For example:
(or viceversa).Much better!