Skip to main content

SSH

Faire un SSH via un proxy : 
# Forward le trafic sur le port 8080 de mon ordinateur vers le port 80 de l'hote distant 
ssh -L 8080:localhost:80 remote_host

Supprimer un hostname des know_host ssh : 

ssh-keygen -R hostname

 

 

 

SSHD - Only sftp

Prérequits :

  • home de l'user toto : /opt/toto

Configuration /etc/ssh/sshd_config : 

Match User toto
     ChrootDirectory /opt/toto
     X11Forwarding no
     AllowTcpForwarding no
     AllowAgentForwarding no
     PasswordAuthentication no
     ForceCommand internal-sftp -d /%u

Commandes pour rendre la chose fonctionelle : 

mkdir /opt/toto/data
chown root:root /opt/toto
chown -R toto:toot /opt/toto/*
systemctl restard sshd

Test : 

sftp -i id_rsa toto@SERVEUR <<< 'put fichier.txt /data/'

# Test de perms
ssh -i id_rsa toto@SERVEUR
This service allows sftp connections only.
Connection to SERVEUR closed.