| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente |
| linux:ssh [2022/03/12 23:07] – add limitations to authorized keys phsw | linux:ssh [2024/09/03 09:29] (Version actuelle) – [Créer un tunnel de port-forwarding] add link phsw |
|---|
| * ''-o'': préciser des options (un ''-o'' par option) | * ''-o'': préciser des options (un ''-o'' par option) |
| * ''-L'': forward un port local vers un port sur une machine distant: ''ssh -L <adresselocale>:<portlocal>:<adressedistante>:<portdistant>'' | * ''-L'': forward un port local vers un port sur une machine distant: ''ssh -L <adresselocale>:<portlocal>:<adressedistante>:<portdistant>'' |
| * ''-D'': forward dynamique de port: ''ssh -D 8080 toor@ip'' | |
| * ''-F'': indique quel fichier ''ssh/config'' utiliser. ''-F /dev/null'' correspond à n'utiliser aucun fichier de configuration. | * ''-F'': indique quel fichier ''ssh/config'' utiliser. ''-F /dev/null'' correspond à n'utiliser aucun fichier de configuration. |
| |
| * [[https://lord.re/posts/187-ssh-key-restricted-rsync-backup/]] | * [[https://lord.re/posts/187-ssh-key-restricted-rsync-backup/]] |
| * [[https://blog.g3rt.nl/upgrade-your-ssh-keys.html]] | * [[https://blog.g3rt.nl/upgrade-your-ssh-keys.html]] |
| | * [[https://github.com/opsdisk/the_cyber_plumbers_handbook|The Cyber Plumber's Handbook - The definitive guide to Secure Shell (SSH) tunneling, port redirection, and bending traffic like a boss]] |
| | * [[https://grahamhelton.com/blog/ssh-cheatsheet/|An Excruciatingly Detailed Guide To SSH (But Only The Things I Actually Find Useful)]] |
| | * [[https://blog.stephane-robert.info/docs/securiser/durcissement/ssh/|Durcir la configuration SSH]] |
| | |
| | |
| | <code bash> |
| | ssh-keygen -t ed25519 -a 100 -C "Comment" |
| | </code> |
| |
| |
| |
| * [[https://goteleport.com/blog/ssh-tunneling-explained/]] | * [[https://goteleport.com/blog/ssh-tunneling-explained/]] |
| | * [[https://iximiuz.com/en/posts/ssh-tunnels/|A Visual Guide to SSH Tunnels (with labs)]] |
| | * [[https://blog.stephane-robert.info/docs/services/reseau/ssh-tunneling/|Maitrisez le tunneling SSH]] |
| |
| |
| |
| [[https://dev.to/samuyi/the-how-to-of-ssh-port-forwarding-1f4e|Source]] | [[https://dev.to/samuyi/the-how-to-of-ssh-port-forwarding-1f4e|Source]] |
| | |
| | |
| | |
| | === Tunnel de port dynamique === |
| | |
| | Si seule la machine A peut accéder à la machine B et qu'on a une connexion à la machine A : |
| | <code bash> |
| | ssh -ND 8080 A |
| | </code> |
| | Cela crée un proxy socks qui écoute sur le port 8080 de la machine local. On peut ensuite configurer Firefox (''about:profiles'' pour le faire uniquement dans un profil spécifique) pour utiliser ce proxy (proxy SOCKSv5 sur 127.0.0.1:8080). |
| |
| |
| <code bash> | <code bash> |
| mkdir -p /run/sshd | mkdir -p /run/sshd |
| | </code> |
| | |
| | |
| | ==== Changer le port d'écoute ==== |
| | |
| | Changer dans le fichier ''/etc/ssh/sshd_config''. Si SystemD est utilisé, il faut aussi modifier le service qui définit la socket ([[https://askubuntu.com/questions/925452/ssh-resets-to-default-port-on-reboot|source]]) : |
| | <code bash> |
| | systemctl edit ssh.socket |
| | </code> |
| | Puis y mettre : |
| | <code> |
| | [Socket] |
| | ListenStream= |
| | ListenStream=3233 |
| </code> | </code> |
| |
| |