{{tag>Serveur SFTP}} # Monter un serveur SFTP (SSH) avec ProFTPd Voir : http://linuxfr.org/news/se-passer-de-dropbox-en-montant-son-coffre-fort-numerique-a-la-maison Voir aussi : * https://www.linuxjournal.com/content/sftp-port-forwarding-enabling-suppressed-functionality * [[Notes rclone]] ** Ne pas confondre FTPS avec SFTP ! ** ~~~bash apt-get install proftpd-basic ~~~ `/etc/proftpd/proftpd.conf` ~~~apache # # Allow from 127.0.0.1 192.168.1.0/8 # Allow from 78.233.103.193 # DenyAll # ####### ## ## SFTP Config SFTPEngine On Port SFTPHostKey /etc/ssh/ssh_host_rsa_key SFTPHostKey /etc/ssh/ssh_host_dsa_key SFTPClientMatch "WS_FTP" channelWindowSize 1GB # enable for sftp debugging: TraceLog /var/log/proftpd/sftp-trace.log #Trace scp:20 sftp:20 ssh2:20 Trace scp:7 sftp:7 ssh2:7 ## End SFTP Config ## SFTPLog /var/log/proftpd/sftp.log TransferLog /var/log/proftpd/sftp-xferlog SFTPAuthMethods publickey password #SFTPAuthMethods publickey AuthUserFile /etc/proftpd/sftp.passwd #SFTPAuthorizedUserKeys file:/etc/proftpd/authorized_keys/%u SFTPAuthorizedUserKeys file:/etc/proftpd/sftp.passwd.keys/%u # SFTP specific configuration #DefaultRoot ~ DefaultRoot /partage # Enable compression SFTPCompression delayed ###### ~~~ `/etc/proftpd/sftp.passwd` ~~~ :<$1$PASSWORD.>:1005:1008::/partage:/usr/bin/rssh ~~~ `/etc/rssh.conf` ~~~ user=:007:000110:"/partage" ~~~ Déposez les clef SSH publiques (à convertir) /etc/proftpd/sftp.passwd.keys/ Now fill the file with the SSH public keys you want. You need to convert it in RFC4716 style before: ~~~bash ssh-keygen -e -f id_rsa.pub > /etc/proftpd/sftp.passwd.keys/virtual2 ~~~ ~~~bash mkdir /etc/proftpd/authorized_keys ssh-keygen -e -f id_rsa.pub > /etc/proftpd/authorized_keys/jean chmod 600 /etc/proftpd/authorized_keys chmod 600 /etc/proftpd/authorized_keys/* service proftpd restart ~~~ ## Installation sur Debian ou Ubuntu Avant toute chose vérifier que votre système d'exploitation soit à jour ~~~bash sudo -s apt-get update apt-get upgrade apt-get dist-upgrade apt-get install proftpd-basic rssh mkdir -p /partage/jean mkdir -p /partage/public addgroup sftp chgrp sftp /partage -R chmod 750 /partage/* chmod 1777 /partage/public ~~~ ~~~apache Allow from 78.234.113.74 127.0.0.1 192.168.2.0/8 DenyAll ~~~ ~~~ ####### ## SFTP Config SFTPEngine On Port 7010 SFTPHostKey /etc/ssh/ssh_host_rsa_key SFTPHostKey /etc/ssh/ssh_host_dsa_key SFTPClientMatch "WS_FTP" channelWindowSize 1GB # enable for sftp debugging: TraceLog /var/log/proftpd/sftp-trace.log #Trace scp:20 sftp:20 ssh2:20 Trace scp:7 sftp:7 ssh2:7 SFTPLog /var/log/proftpd/sftp.log TransferLog /var/log/proftpd/sftp-xferlog SFTPAuthMethods publickey password AuthUserFile /etc/proftpd/sftp.passwd SFTPAuthorizedUserKeys file:/etc/proftpd/sftp.passwd.keys/%u # SFTP specific configuration DefaultRoot ~ # Enable compression SFTPCompression delayed ###### Commenter Changer : Port Umask 007 007 #TransferLog ~~~ ~~~ $ getent group sftp |cut -d':' -f3 1008 ~~~ ~~~ $ mkpasswd --hash=md5 $PASS $1$L0PQHYcl$fUkBeMISuAg.miC0qJONP. ~~~ ~~~bash cat >>/etc/proftpd/sftp.passwd