SSH and SCP: Difference between revisions

From Arbeitsgruppe Kuiper
Jump to navigation Jump to search
(Info on -p flag added)
m (Formatting, clarity)
Line 5: Line 5:
=== Inside the university ===
=== Inside the university ===


To connect to Asterope or Merope simply use the command
To connect to Asterope or Merope simply use, where <code><USERNAME></code> has the format <code>xyz123a</code>, the command:
 
<code>ssh <USERNAME>@asterope.agk.uni-due.de</code>


<code>ssh cbi586j@asterope.agk.uni-due.de</code>


=== From outside of the university ===
=== From outside of the university ===
Line 20: Line 21:
<code>ssh -4 <username>@staff.uni-due.de</code>
<code>ssh -4 <username>@staff.uni-due.de</code>


followed by
The <code>-4</code> specifies to use IPv4 for the connection. Then, to connect to Asterope:


<code>ssh -p 54321 localhost</code>
<code>ssh -p 54321 localhost</code>


to connect to Asterope.
The <code>-p</code> tells <code>ssh</code> specifies the port for the connection. From there, you can do simply <code>ssh merope</code> to reach Merope (as the same user).


The <code>-4</code> specifies to use IPv4 for the connection and the <code>-p</code> tells ssh to use a specific port for the connection.
To get a direct pipeline to Asterope you can use  


To get a direct pipeline you can use
<code>ssh -p 54321 -J <username>@staff.uni-due.de <username>@localhost</code>


<code>ssh -p 54321 -J <username>@staff.uni-due.de <username>@localhost</code>
If you want graphics windows, use the <code>-X</code> flag with the <code>ssh</code> call(s).


== SCP ==
== SCP ==

Revision as of 11:57, 30 December 2023

We need the SSH and SCP commands to access the different clusters of the group. As soon as your user ID is working, Lothar can give you access to the two servers Asterope and Merope.

SSH

Inside the university

To connect to Asterope or Merope simply use, where <USERNAME> has the format xyz123a, the command:

ssh <USERNAME>@asterope.agk.uni-due.de


From outside of the university

To access the university network from outside, we need to establish a VPN connection using Forcepoint. The command needed to connect is:

sudo forcepoint-client vpn.uni-due.de --resolver /usr/bin/resolvectl

Since the university does not allow direct forwarding to the group servers we need to take a detour over the staff server. This is done by the following command:

ssh -4 <username>@staff.uni-due.de

The -4 specifies to use IPv4 for the connection. Then, to connect to Asterope:

ssh -p 54321 localhost

The -p tells ssh specifies the port for the connection. From there, you can do simply ssh merope to reach Merope (as the same user).

To get a direct pipeline to Asterope you can use

ssh -p 54321 -J <username>@staff.uni-due.de <username>@localhost

If you want graphics windows, use the -X flag with the ssh call(s).

SCP

SCP from inside the university network is very straightforward. The needed command is

scp -pr <username>@asterope.agk.uni-due.de:asterope-home/some/folder/somewhere/somedata.data

To transfer data from Asterope to your local machine while using the VPN, I use a two-step system where I first transfer the data into a clipboard folder on the staff server and afterwards onto my local machine. The needed commands for this version are:

scp -pr -P 54321 <username>@localhost:/homes/<username>/asterope-home/some/folder/somewhere/somedata.data clipboard/

scp -pr -4 <username>@staff.uni-due.de:clipboard/somedata.data /home/some/path/to/somewhere/

The -r is needed to copy folders and not just single files, the -P to specify a port to which to connect to. Note that for scp, in contrast to ssh, this p is uppercase. The direct forwarding from above works here as well, just replace the -p flag by -P.

It is good practice to use the (lowercase) -p flag (note how flags can be written together: -pr4 or -p -r -4 would also work) to preserve the timestamp on the file(s); otherwise, the timestamp is set to the time of copy, which is "not true" and possibly confusing (the file was not modified, just transfered).

A more powerful command that is resilient to network interruptions, has optimisations that are important especially for large files, etc. is rsync.