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 [16/08/2017 10:10] – [Clients pour Windows] 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 =====
  
-Dans /etc/ssh/sshd_config tu change la ligne  +Afficher et tester la configuration complète (variables config & default) : 
-  PermitRootLogin Yes  + 
-  en  +<code> 
-  PermitRootLogin No+# Afficher et tester 
 +sudo sshd -T 
 +# Juste tester 
 +sudo sshd -t 
 +</code> 
 + 
 +Dans /etc/ssh/sshd_config tu change la ligne 
 + 
 +<code> 
 +PermitRootLogin Yes 
 +en 
 +PermitRootLogin No 
 +</code> 
 Et si tu veux autoriser l'accès ssh en root uniquement avec clé ssh tu mets : Et si tu veux autoriser l'accès ssh en root uniquement avec clé ssh tu mets :
-  PermitRootLogin without-password 
-Mais bon ça marche pas ... 
  
-Voici une config qui fontionne : +<code> 
-  UsePAM no +PermitRootLogin without-password 
-  RSAAuthentication yes +</code> 
-  PermitRootLogin without-password + 
-  PermitEmptyPasswords no +Une configuration solide
-  PasswordAuthentication no  + 
-et une autre +<code> 
-  UsePAM no +/etc/ssh/sshd_config.d/99_custom.conf 
-  Subsystem sftp /usr/libexec/openssh/sftp-server + 
-  IgnoreRhosts yes +#Port non standard: réduit le bruit malveillants 
-  IgnoreUserKnownHosts no + 
-  PrintMotd yes +MaxAuthTries 3 
-  StrictModes yes +LoginGraceTime 5 
-  RSAAuthentication yes +PermitRootLogin no 
-  PermitRootLogin no +PasswordAuthentication no 
-  PermitEmptyPasswords no +PermitEmptyPasswords no 
-  PasswordAuthentication no+KbdInteractiveAuthentication no 
 +#ChallengeResponseAuthentication no 
 +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 
 + 
 +#UsePAM yes ??? 
 +#  -  ^=^s  Check which modules are active 
 + 
 +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 2 
 +TCPKeepAlive yes 
 + 
 +</code> 
  
 ===== Clients ===== ===== Clients =====
Ligne 54: 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 65: Ligne 122:
   # ATTENTION : local5 est utilisé notamment par sshd   # ATTENTION : local5 est utilisé notamment par sshd
   local5.info /var/log/sshd   local5.info /var/log/sshd
 +
 +Le port 22 est scanné en permanence, ce qui rempli le disque (risque [[glossaire/DDOS]]):
 +<code bash>
 +root@seriously:~# ls -lhS /var/log/|head
 +total 13M
 +-rw-rw----  1 root  utmp  36M Jul 10 12:09 btmp
 +-rw-r-----  1 root  adm   25M Jul  4 06:13 auth.log.1
 +-rw-r-----  1 root  adm   24M Jul 10 12:09 auth.log
 +-rw-------  1 root  utmp  13M Jul  1 06:12 btmp.1
 +</code>
  
 ==== Email automatique lors de la connexion ==== ==== Email automatique lors de la connexion ====
Ligne 77: 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 88: 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 106: 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.1502871042.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