informatique:reseau:ssh
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| informatique:reseau:ssh [10/07/2021 14:19] – [Logs] cyrille | informatique:reseau:ssh [21/06/2026 08:01] (Version actuelle) – [Configuration] cyrille | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | ====== Secure SHell ====== | + | ====== Secure SHell (SSH) ====== |
| + | |||
| + | * https:// | ||
| + | |||
| + | Guides pour configurer et durcir ssh: | ||
| + | - https:// | ||
| + | - https:// | ||
| ===== Configuration ===== | ===== Configuration ===== | ||
| + | |||
| + | Afficher et tester la configuration complète (variables config & default) : | ||
| + | |||
| + | < | ||
| + | # Afficher et tester | ||
| + | sudo sshd -T | ||
| + | # Juste tester | ||
| + | sudo sshd -t | ||
| + | </ | ||
| Dans / | Dans / | ||
| Ligne 17: | Ligne 32: | ||
| </ | </ | ||
| - | Mais bon ça marche pas … | + | Une configuration solide: |
| - | + | ||
| - | Voici une config qui fontionne | + | |
| < | < | ||
| - | UsePAM no | + | # /etc/ |
| - | RSAAuthentication yes | + | |
| - | PermitRootLogin without-password | + | |
| - | PermitEmptyPasswords no | + | |
| - | PasswordAuthentication no | + | |
| - | </code> | + | |
| - | et une autre : | + | #Port non standard: réduit le bruit malveillants |
| - | < | + | MaxAuthTries 3 |
| - | UsePAM no | + | LoginGraceTime 5 |
| - | Subsystem | + | |
| - | IgnoreRhosts yes | + | |
| - | IgnoreUserKnownHosts no | + | |
| - | PrintMotd yes | + | |
| - | StrictModes yes | + | |
| - | RSAAuthentication yes | + | |
| PermitRootLogin no | PermitRootLogin no | ||
| + | PasswordAuthentication no | ||
| PermitEmptyPasswords no | PermitEmptyPasswords no | ||
| - | PasswordAuthentication | + | KbdInteractiveAuthentication |
| - | </code> | + | # |
| - | ==== Maintien de la connexion ==== | + | HostbasedAuthentication no |
| + | KerberosAuthentication no | ||
| + | GSSAPIAuthentication no | ||
| + | PubkeyAuthentication yes | ||
| + | AuthorizedKeysFile .ssh/authorized_keys .ssh/ | ||
| + | StrictModes yes | ||
| + | Compression no | ||
| + | AllowTcpForwarding no | ||
| + | X11Forwarding no | ||
| + | AllowAgentForwarding no | ||
| + | AllowStreamLocalForwarding no | ||
| + | IgnoreRhosts yes | ||
| - | < | + | #UsePAM yes ??? |
| - | ServerAliveCountMax | + | # - ^=^s Check which modules are active |
| - | </ | + | |
| - | ''ClientAliveInterval'' | + | HostKeyAlgorithms ssh-ed25519, |
| + | PubkeyAcceptedKeyTypes ssh-ed25519, | ||
| + | MACs hmac-sha2-512-etm@openssh.com, | ||
| + | |||
| + | # remove LC_* to avoid some "Can't set locale; make sure $LC_* and $LANG are correct!" | ||
| + | AcceptEnv LANG | ||
| + | |||
| + | ClientAliveInterval | ||
| + | ClientAliveCountMax | ||
| + | TCPKeepAlive yes | ||
| + | |||
| + | </ | ||
| Ligne 77: | Ligne 101: | ||
| * [[http:// | * [[http:// | ||
| * ssh-agent | * ssh-agent | ||
| + | |||
| + | ==== sshfs ==== | ||
| + | |||
| + | Permet de monter un filesystem distant via ssh | ||
| + | |||
| + | * https:// | ||
| + | |||
| + | < | ||
| + | sshfs -p < | ||
| + | </ | ||
| ===== Tips ===== | ===== Tips ===== | ||
| Ligne 110: | Ligne 144: | ||
| ==== Blacklister les Ips indésirables ==== | ==== Blacklister les Ips indésirables ==== | ||
| - | Avec le script ssh-blacklist, voir [[informatique/ | + | SSH scanning ssh-blacklist |
| + | |||
| + | Blacklister les Ips indésirables avec le script | ||
| ==== Chroot Jail ==== | ==== Chroot Jail ==== | ||
| Ligne 121: | Ligne 157: | ||
| RSSH: http:// | RSSH: http:// | ||
| + | |||
| ==== Tunnel ==== | ==== Tunnel ==== | ||
| Ssh tunneling (Encrypt your HTTP Traffic and more): | Ssh tunneling (Encrypt your HTTP Traffic and more): | ||
| + | |||
| + | * https:// | ||
| Vous créez un port d' | Vous créez un port d' | ||
| Ligne 139: | Ligne 178: | ||
| Ne fonctionne pas toujours avec ' | Ne fonctionne pas toujours avec ' | ||
| ssh -N -L 127.0.0.1: | ssh -N -L 127.0.0.1: | ||
| + | |||
| + | |||
| + | === Proxying === | ||
| + | |||
| + | <code bash> | ||
| + | scp -o ' | ||
| + | </ | ||
| Se connecter à un serveur via un autre serveur (forwarding agent): | Se connecter à un serveur via un autre serveur (forwarding agent): | ||
| ssh -p <public port> -t -A root@< | ssh -p <public port> -t -A root@< | ||
| + | |||
| + | proxying (JumpHost): | ||
| + | |||
| + | ssh -J jump-user@jump.net: | ||
| Via la configuration du client SSH, ce qui du coup fonctionne avec SCP: | Via la configuration du client SSH, ce qui du coup fonctionne avec SCP: | ||
| - | | + | < |
| Host machineC | Host machineC | ||
| ProxyCommand ssh -p XXX user@machineB nc %h %p | ProxyCommand ssh -p XXX user@machineB nc %h %p | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | host un-nom-raccourci | ||
| + | Hostname destination.finale.net | ||
| + | ProxyCommand ssh -p 666 -W %h:22 user-passerelle@passerelle.ssh.net | ||
| + | User user-destination | ||
| + | IdentityFile $SSHKEY | ||
| + | </ | ||
| Ouvrir une console via une autre machine: | Ouvrir une console via une autre machine: | ||
informatique/reseau/ssh.1625919554.txt.gz · Dernière modification : de cyrille
