This is an old revision of the document!
Everything you always wanted to know about ssh, ssh keys, the passphrase and ssh agent, but were afraid to ask
At least everything you need to know, without getting bored to death
ssh
is a program for logging securely into a remote machine and for executing commands on a remote machinessh
is an SSH client using the SSH protocolmy_login
account on the remote remote_server
computer, and you know your passwordscp
(copy remote directories and files), rsync
(synchronize remote directories and files), …telnet
, rlogin
, rsh
, ftp
, …
Note: the following will work in a Linux terminal, but can also work in a terminal on a Mac or on a Windows 10 computer (ssh
is directly available in Windows Powershell
, Windows Terminal
or the old cmd
, but it is not the best way to use ssh
on Windows)
ssh [options] [my_login@]remote_server
my_login@
: e.g. just use ssh ssh1.lsce.ipsl.fr
-X
: Enable X11 forwarding. This option will allow you to start graphical programs on the remote server-X
does not work, use -Y
instead (Enable trusted X11 forwarding)-X
/-Y
option will automatically define the DISPLAY
environment variable that is required by graphical programs on the remote server. Otherwise, DISPLAY
will not be definedjypeter@lsce5203:~$ echo $DISPLAY localhost:0.0 jypeter@lsce5203:~$ ssh ssh1.lsce.ipsl.fr Last login: Wed Jul 8 14:45:31 2020 from 176-142-31-75.abo.bbox.fr [jypeter@ssh1 ~]$ echo $DISPLAY DISPLAY: Undefined variable. [jypeter@ssh1 ~]$ logout Connection to ssh1.lsce.ipsl.fr closed. jypeter@lsce5203:~$ ssh -X ssh1.lsce.ipsl.fr [jypeter@ssh1 ~]$ echo $DISPLAY localhost:43.0
-A
: enable agent forwarding. This is useful when you use ssh keys, and an ssh agent-t command
: this option allows you to execute a command on the remote server (without displaying the output of the initial ssh
). We use this mostly to chain ssh connections, when we want to automatically go through a specific gateway server to access another serverssh -A -X my_login@ssh1.lsce.ipsl.fr -t ssh -A -X obelix
-v
: verbose mode. Use this option only when you can't connect, or things don't seem to work correctly. Analyzing the verbose output when you start ssh
should allow you, or the system administrators, to find out what is wrong
If you want to easily use ssh
(with the appropriate options), you should define the following aliases in your ~/.bashrc
configuration file
alias obelix='ssh -A -X my_LSCE_login@ssh1.lsce.ipsl.fr -t ssh -A -X obelix' alias ciclad='ssh -A -X my_ciclad_login@ciclad.ipsl.jussieu.fr'
ssh
will store all its configuration files in the ~/.ssh/
directory (C:\Users\your_windows_login\.ssh
on Windows 10)
known_hosts
: the first time you connect to a new server, ssh
will ask if you are sure of what you are doing, and then store some unique information about the remote server in the known_hosts
file. It will check this information (without asking you) the next time you connect to the same server, and warn you if something seems wrongconfig
: an optional configuration fileauthorized_keys
, and possibly your private and public ssh keysman ssh
[ PMIP3 Wiki Home ] - [ Help! ] - [ Wiki syntax ]