User Tools

Site Tools


doc:appunti:linux:sa:ssh

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
doc:appunti:linux:sa:ssh [2010/12/05 18:20] niccolodoc:appunti:linux:sa:ssh [2022/02/11 11:22] – [rush] niccolo
Line 1: Line 1:
 ====== SSH e SFTP ====== ====== SSH e SFTP ======
 +
 +===== sftp e rssh =====
  
 Per poter effettuare **sftp** è necessario avere una shell valida, per evitare di dare accesso shell completo si può utilizzare **rssh**, una shell ridotta che dovrebbe consentire solo scp, sftp, cvs, rsync e rdist. Per poter effettuare **sftp** è necessario avere una shell valida, per evitare di dare accesso shell completo si può utilizzare **rssh**, una shell ridotta che dovrebbe consentire solo scp, sftp, cvs, rsync e rdist.
Line 9: Line 11:
 <file> <file>
 user=loginname:011:000110: # Allow sftp and scp, no chroot. user=loginname:011:000110: # Allow sftp and scp, no chroot.
 +</file>
 +
 +==== rush ====
 +
 +In **Debian 10 Buster** non esiste il pacchetto **rssh**, al suo posto troviamo **rush**. Segue una breve ricetta su come attivare un ambiente **rush** per un utente, limitato a **ricevere dei file via sftp**.
 +
 +Si installa il server SFTP:
 +
 +<code>
 +apt install openssh-sftp-server
 +</code>
 +
 +quindi si prepara un ambiente chroot che servirà a tenere confinato l'utente remoto che accede via SFTP. La directory **/srv/rush/** occuperà circa **280 Mb** (Debian Buster):
 +
 +<code>
 +apt install rush
 +adduser --uid 1004 --gecos "Special SFTP account" --shell "/usr/sbin/rush" sftp-user
 +mkdir -p /srv/rush/
 +debootstrap buster /srv/rush/
 +</code>
 +
 +Nell'ambiente chroot si eseguono alcune operazioni:
 +
 +<code>
 +chroot /srv/rush
 +
 +apt install locales
 +dpkg-reconfigure locales
 +apt install openssh-sftp-server
 +adduser --uid 1004 --gecos "Special SFTP account" --shell "/bin/false" sftp-user
 +</code>
 +
 +Il file **/etc/rush.rc** dovrà contenere la sezione:
 +
 +<file>
 +# Sftp-server requests: chroot to the virtual server, change to the user's
 +#                       home directory, set umask to 002 and execute only
 +#                       /usr/lib/sftp-server.
 +#
 +# Setting for a chroot directory created using 'debootstrap'.
 +#
 +# Remark: The location '/usr/lib/' is inherited.
 +
 +rule sftp-rush
 +  command ^.*/sftp-server
 +  uid >= 1000
 +  set[0] /usr/lib/sftp-server
 +  umask 002
 +  chroot /srv/rush
 +  chdir ~
 </file> </file>
  
 ===== SSH su Windows ===== ===== SSH su Windows =====
  
-Dopo aver installato il programma, si esegue **''ssh-host-config''** per configurare il servizio.+Dopo aver installato il programma con l'installer di **[[http://www.cygwin.com/|Cygwin]]**, si esegue **''ssh-host-config''** per configurare il servizio.
  
 L'utente con cui gira il servizio ''sshd'' deve avere i seguenti permessi: L'utente con cui gira il servizio ''sshd'' deve avere i seguenti permessi:
Line 30: Line 82:
 <code> <code>
 sc \\server_name delete sshd sc \\server_name delete sshd
 +</code>
 +
 +===== Affidabilità di rsync su ssh =====
 +
 +Se si esegue un rsync di grosse quantità di dati su connessione ssh e la linea non è molto affidabilie, si rischia di avere vari tipi di errore del tipo **broken pipe**.
 +
 +Con opportune opzioni si dovrebbe aumentare l'affidabilità:
 +
 +<code bash>
 +# ServerAliveInterval and ServerAliveCountMax:
 +#  * Terminate the session if server does not respond for 4 min:
 +#    15 x 20 = 300 s => 5 min
 +
 +# TCPKeepAlive:
 +#  * Detect TCP/IP network down (also temporary).
 +#
 +# IPQoS
 +#  * IPv4 type-of-service
 +
 +SSH_OPTIONS='-o ServerAliveInterval=15 -o ServerAliveCountMax=20 -o TCPKeepAlive=no -o IPQoS=reliability'
 +
 +rsync -avz --delete -e "ssh $SSH_OPTIONS" "${REMOTE}:${SRC_DIR}/" "${DST_DIR}"
 </code> </code>
  
doc/appunti/linux/sa/ssh.txt · Last modified: 2022/02/11 11:30 by niccolo