Accueil·Commandes du terminal

ssh

Réseau

Syntaxe

ssh [-p <port>] <user>@<host> [command]

Ouvre un shell chiffre sur une autre machine ; ssh refuse categoriquement une cle privee lisible par autrui, faites-lui donc `chmod 600`, et le port s'ecrit `-p` ici mais `-P` avec scp et sftp.

Options courantes

OptionSignification
-p 2222Port. Note that scp and sftp spell the same thing -P.
-i ~/.ssh/id_ed25519Use a specific private key.
-L 8080:localhost:80Local forward: your port 8080 reaches the remote side.
-R 9000:localhost:3000Remote forward: their port 9000 reaches your machine.
-D 1080A local SOCKS proxy tunnelled through the host.
-J <bastion>Jump through a bastion host in one command.
-N -fNo remote command, go to the background. The pair used for tunnels.
-v / -vvvShow the handshake, which is how you find out why a key was refused.
-o <Option>=<value>Any ssh_config setting for this one connection.

Exemples

ssh -p 2222 deploy@example.com

Log in on a non-standard port.

ssh -N -L 5432:localhost:5432 deploy@db.example.com

Reach the remote database as if it were local.

ssh -vvv git@github.com

See exactly which keys were offered and rejected.

Quand une connexion échoue, ceux-ci délimitent jusqu’où elle est allée : le nom ne se résout pas, pas de route, ou le port est fermé.

Comment lire

  • Les crochets [ ] marquent une partie facultative.
  • Les points de suspension … signifient qu’on peut en mettre plusieurs.
  • Les options sont sensibles à la casse : sur certaines commandes, -r et -R ne font pas la même chose.

Questions fréquentes

Q. Que fait ssh ?

Ouvre un shell chiffre sur une autre machine ; ssh refuse categoriquement une cle privee lisible par autrui, faites-lui donc `chmod 600`, et le port s'ecrit `-p` ici mais `-P` avec scp et sftp.

Q. Comment l’écrire ?

ssh [-p <port>] <user>@<host> [command] — les crochets marquent ce qui est facultatif.

Q. Combien d’options valent la peine ?

Il y en a 9 ici ; la liste complète est dans man ssh. Cette commande relève de Réseau.

Commandes liées

page man: man ssh