Outils pour utilisateurs

Outils du site


informatique:reseau:ssh

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
informatique:reseau:ssh [10/07/2021 14:19] – [Logs] cyrilleinformatique:reseau:ssh [21/06/2026 08:01] (Version actuelle) – [Configuration] cyrille
Ligne 1: Ligne 1:
-====== Secure SHell ======+====== Secure SHell (SSH) ====== 
 + 
 +  * https://man.openbsd.org/sshd_config 
 + 
 +Guides pour configurer et durcir ssh: 
 +  - https://www.digitalocean.com/community/tutorials/ssh-essentials-working-with-ssh-servers-clients-and-keys 
 +  - https://infosec.mozilla.org/guidelines/openssh
  
 ===== Configuration ===== ===== Configuration =====
 +
 +Afficher et tester la configuration complète (variables config & default) :
 +
 +<code>
 +# Afficher et tester
 +sudo sshd -T
 +# Juste tester
 +sudo sshd -t
 +</code>
  
 Dans /etc/ssh/sshd_config tu change la ligne Dans /etc/ssh/sshd_config tu change la ligne
Ligne 17: Ligne 32:
 </code> </code>
  
-Mais bon ça marche pas … +Une configuration solide:
- +
-Voici une config qui fontionne :+
  
 <code> <code>
-UsePAM no +/etc/ssh/sshd_config.d/99_custom.conf
-RSAAuthentication yes +
-PermitRootLogin without-password +
-PermitEmptyPasswords no +
-PasswordAuthentication no +
-</code>+
  
-et une autre :+#Port non standardréduit le bruit malveillants
  
-<code> +MaxAuthTries 3 
-UsePAM no +LoginGraceTime 5
-Subsystem    sftp    /usr/libexec/openssh/sftp-server +
-IgnoreRhosts yes +
-IgnoreUserKnownHosts no +
-PrintMotd yes +
-StrictModes yes +
-RSAAuthentication yes+
 PermitRootLogin no PermitRootLogin no
 +PasswordAuthentication no
 PermitEmptyPasswords no PermitEmptyPasswords no
-PasswordAuthentication no +KbdInteractiveAuthentication no 
-</code> +#ChallengeResponseAuthentication no 
-==== Maintien de la connexion ====+HostbasedAuthentication no 
 +KerberosAuthentication no 
 +GSSAPIAuthentication no 
 +PubkeyAuthentication yes 
 +AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 
 +StrictModes yes 
 +Compression no 
 +AllowTcpForwarding no 
 +X11Forwarding no 
 +AllowAgentForwarding no 
 +AllowStreamLocalForwarding no 
 +IgnoreRhosts yes
  
-<code>ServerAliveInterval +#UsePAM yes ??? 
-ServerAliveCountMax +#  -  ^=^s  Check which modules are active
-</code>+
  
-''ClientAliveInterval'' dit d'envoyer un paquet de vérification toutes les xx secondes (défaut: 0) et ''ClientAliveCountMax'' dit de couper la connexion après x messages sans réponse (défaut: 3)+HostKeyAlgorithms ssh-ed25519,rsa-sha2-512 
 +PubkeyAcceptedKeyTypes ssh-ed25519,rsa-sha2-512,rsa-sha2-256 
 +MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com 
 + 
 +# remove LC_* to avoid some "Can't set locale; make sure $LC_* and $LANG are correct!" 
 +AcceptEnv LANG 
 + 
 +ClientAliveInterval 20 
 +ClientAliveCountMax 
 +TCPKeepAlive yes 
 + 
 +</code>
  
  
Ligne 77: Ligne 101:
   * [[http://live.gnome.org/GnomeKeyring|GNOME Keyring]], [[wpen>GNOME_Keyring]], [[http://library.gnome.org/devel/gnome-keyring/stable/|gnome-keyring Reference Manual]]   * [[http://live.gnome.org/GnomeKeyring|GNOME Keyring]], [[wpen>GNOME_Keyring]], [[http://library.gnome.org/devel/gnome-keyring/stable/|gnome-keyring Reference Manual]]
   * ssh-agent   * ssh-agent
 +
 +==== sshfs ====
 +
 +Permet de monter un filesystem distant via ssh
 +
 +  * https://doc.ubuntu-fr.org/sshfs
 +
 +<code>
 +sshfs -p <port> user@sftp-server.net:/home/user/ local-folder
 +</code>
  
 ===== Tips ===== ===== Tips =====
Ligne 110: Ligne 144:
 ==== Blacklister les Ips indésirables ==== ==== Blacklister les Ips indésirables ====
  
-Avec le script ssh-blacklist, voir [[informatique/security#ssh_scanning]].+SSH scanning ssh-blacklist 
 + 
 +Blacklister les Ips indésirables avec le script http://www.frit.net/scripts/ {{:informatique:ssh-blacklist.zip|copie locale}}
  
 ==== Chroot Jail ==== ==== Chroot Jail ====
Ligne 121: Ligne 157:
  
 RSSH: http://www.pizzashack.org/rssh RSSH: http://www.pizzashack.org/rssh
 +
  
 ==== Tunnel ==== ==== Tunnel ====
  
 Ssh tunneling (Encrypt your HTTP Traffic and more): Ssh tunneling (Encrypt your HTTP Traffic and more):
 +
 +  * https://www.digitalocean.com/community/tutorials/ssh-essentials-working-with-ssh-servers-clients-and-keys#setting-up-ssh-tunnels
  
 Vous créez un port d'écoute qui se charge de prendre toute trame réseau qui rentre “telle quelle” et de la faire exécuter depuis l'autre bout du tunnel. Vous créez un port d'écoute qui se charge de prendre toute trame réseau qui rentre “telle quelle” et de la faire exécuter depuis l'autre bout du tunnel.
Ligne 139: Ligne 178:
 Ne fonctionne pas toujours avec 'localhost', utiliser alors '127.0.0.1' Ne fonctionne pas toujours avec 'localhost', utiliser alors '127.0.0.1'
   ssh -N -L 127.0.0.1:3307:127.0.0.1:3306 -p 30001 USER@REMOTE_HOST   ssh -N -L 127.0.0.1:3307:127.0.0.1:3306 -p 30001 USER@REMOTE_HOST
 +
 +
 +=== Proxying ===
 +
 +<code bash>
 +scp -o 'ProxyJump user@proxy.openstreetmap.fr' ./file user@vm.openstreetmap.fr:/home/user/
 +</code>
  
 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@<public ip> ssh -t root@<private-ip>   ssh -p <public port> -t -A root@<public ip> ssh -t root@<private-ip>
 +
 +proxying (JumpHost):
 +
 +  ssh -J jump-user@jump.net:1234 destination-user@destination.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:
  
-  #~/.ssh/config+<del>  #~/.ssh/config
   Host machineC   Host machineC
  ProxyCommand ssh -p XXX user@machineB nc %h %p  ProxyCommand ssh -p XXX user@machineB nc %h %p
 +</del>
 +
 +<code>
 +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
 +</code>
  
 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

Sauf mention contraire, le contenu de ce wiki est placé sous les termes de la licence suivante : CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki