Standard Training: SSH - Secure Shell Login¶
cryptographic network protocol for, e.g., remote command-line login
Basic Features¶
Remote Login¶
ssh
: remote login
-
login to remote
host
using current username (i.e.,$USER
envirnment variable in Unix-like systems): -
login to remote
host
using specific username (e.g.,foo
):
ssh-keygen
+ssh-copy-id
: password-less login (public-private key pairs)
Be careful not to overwrite your existing ssh keys
- First check for existing keys
- generate a ssh key pair using RSA cryptosystem
Security Note
~/.ssh/id_rsa
: keep it secret (do not share)~/.ssh/id_rsa.pub
share it for remote authentification (see below)
- install public key to remote server
host
(please replacehost
with where you are copying your public key):
Remote File Copy¶
scp
: remote copy over ssh
scp
works similar tocp
and copies filefoo
fromuser1@host1
touser2@host2
asbar
:- When
host
anduser
are not specified they are treated as yourlocalhost
and$USER
; if a path is not given, the path is assumed to be in the$HOME
folder. As an example, to copy a fileoutput
from$HOME
on cruntch4 back to current directory of the local machine can be done via: - To copy, multiple files in one-shot, one can first make a tarball via
tar
and doscp
: - Other remote copying options are:
sftp
orsshfs
. One may also use a GUI to help; see this thread for some options
More Advanced Features (Optional)¶
~/.ssh/config
: custom ssh configurations
To login to hosts with longer name or with a different user id, one can add custom configurations in ~/.ssh/config
- simplify ssh login to from
ssh EUID@cruntch4.chem.unt.edu
tossh cruntch4
, one can add the following lines in~/.ssh/config
(replaceEUID
with your EUID):
ssh (VPN) tunnel
-
build the tunnel with the host and connect to a local port (
5000
in this case) -
set up browser proxy to redirect traffic, e.g., when using Firefox change Connection settings to:
FAQ about SSH¶
Can I use the same SSH for multiple servers?
Yes, it is generally safe and convenient to do so. Related discussions can be found in this thread and this thread