Remote Connections
Connect Remotely with ssh
Secure SHell (SSH) is designed to be a secure way to connect to remote resources from your local machine over an unsecured network. The following example uses an account with username "jolo" using SSH to log into a machine named "foo.edu":
$ ssh jolo@foo.edu
This will open a connection to the remote machine "foo.edu" and log
in as the user if authentication is successful. If you
log into Stampede3
via SSH, a password and/or private key
will be required for authentication. The above example is the most straightforward
version of the command, but there are many additional options. For example,
to use a
key pair
(where my_key
is the name
of the private key file) to login, then the command will look like:
$ ssh -i my_key jolo@foo.edu
Another common option is
X11
forwarding, which can be achieved using the -X
or -Y
flags. X11 forwarding is useful when you are going to use
applications that open up outside of the shell.
For more information on this and other options, see
the man page for ssh
.
SSH setup
In order to access a Linux system via ssh
, you will need an ssh
client and a terminal program on your system. Sometimes these are included
in a single application for simplicity. There are many different terminals
available, but here are a few examples:
- On Linux, simply open your terminal emulator and enter
ssh
commands -
On Mac OS, the Terminal app is included with the system, and
ssh
can be invoked from the command line in the Terminal app -
On Windows:
-
The Linux Bash Shell is available as the
Windows Subsystem for Linux
and supports many Linux commands, including
ssh
- One commonly-used terminal and ssh client combo is PuTTY
- Another terminal and ssh client combo is MobaXterm
-
The Linux Bash Shell is available as the
Windows Subsystem for Linux
and supports many Linux commands, including
Securely Copy with scp
Secure Copy Protocol (SCP) is based on the SSH protocol, and is used for securely copying files across the network.
Copy to a remote resource
Say you have a file
"code.c" located in your current directory on your local machine that
you want to copy to a remote resource in the "Project" directory under your
home directory
on the remote machine (we'll stick with the user "jolo" and "foo.edu").
This can be done using scp
as follows:
$ scp code.c jolo@foo.edu:~/Project
Copy from a remote resource
Alternatively, if you want to copy the file "output.txt" from a remote resource located in the "Project" directory to the directory "Results" on your local machine and rename the file to "Run12_data.txt" during the move:
$ scp jolo@foo.edu:~/Project/output.txt ./Results/Run12_data.txt
Similar syntax can be used to copy from a remote host to another remote host
as well. The -r
option can be used to copy full directories recursively.
For more options, see the scp
man page.
SCP setup
To use scp
with a remote system, similar to ssh
, you
will need a program to support it. Here are a few examples:
- On Linux, open your terminal emulator and enter
scp
commands - On Mac OS, open the Terminal app and enter
scp
commands -
On Windows:
-
The Windows Subsystem for Linux
supports many Linux commands, including
scp
- From the developers of PuTTY, you can use PSCP
- MobaXterm comes with a built-in SCP client
-
The Windows Subsystem for Linux
supports many Linux commands, including
If you are expecting to copy large files to or from remote locations, note that File and Directory Compression will be covered later in this tutorial, under Optional Topics.