sftp - Write failed: Broken pipe

Installazione, configurazione e uso di Ubuntu come server: web, ftp, mail, news, proxy, dns e altro.
lbottoni
Prode Principiante
Messaggi: 75
Iscrizione: giovedì 26 luglio 2007, 11:42

sftp - Write failed: Broken pipe

Messaggio da lbottoni »

Ciao,
ho installato la macchina e provato a creare un'utente per lìaccesso in sftp, ma non riesco a farlo funzionare.

queste sono le modifiche fatte a /etc/ssh/sshd_conf

Codice: Seleziona tutto

Subsystem sftp internal-sftp

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM yes

#_______________match con user _____________________
Match User sftp_develope_reporting
    ChrootDirectory /var/www/reporting.develope.3dlab
    AllowTCPForwarding no
    X11Forwarding no
    ForceCommand internal-sftp



#________________match per gruppo___________________
#Match Group sftp_develope_reporting
#    ChrootDirectory %h
#    AllowTCPForwarding no
#    X11Forwarding no
#    ForceCommand internal-sftp

la cartella /var/www è così settata

Codice: Seleziona tutto

root@capamerica:~$ ls -la /var/www
totale 32
drwxr-xr-x  7 root                    root                    4096 ago  5 10:01 .
drwxr-xr-x 15 root                    root                    4096 ago  5 11:02 ..
-rw-r--r--  1 root                    root                     177 ago  2 09:52 index.html
drwxr-xr-x  5 www-data                root                    4096 ago  2 10:35 parser
drwxr-x---  6 sftp_develope_reporting sftp_develope_reporting 4096 ago  6 09:44 reporting.develope.3dlab
se eseguo la prova di accesso mi chiede la password , ma poi ho questi errori
root@capamerica:~$ sudo sftp sftp_develope_reporting@xxx.xxx.xxx.xxx
sftp_develope_reporting@xxx.xxx.xxx.xxx's password:
Write failed: Broken pipe
Couldn't read packet: Connection reset by peer
con -vvv dopo la password il debug dice
debug3: packet_send2: adding 32 (len 78 padlen 18 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug1: Authentication succeeded (password).
Authenticated to xxx.xxx.xxx.xxx ([xxx.xxx.xxx.xxx]:22).
debug2: fd 4 setting O_NONBLOCK
debug3: fd 5 is O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
Write failed: Broken pipe
Couldn't read packet: Connection reset by peer

credo possa essere un'errore di permessi, ma dopo 2 giorni di prove alzo la mano e chiedo l'aiuto da casa :cry:
lbottoni
Prode Principiante
Messaggi: 75
Iscrizione: giovedì 26 luglio 2007, 11:42

Re: sftp - Write failed: Broken pipe

Messaggio da lbottoni »

Ho messo come chroot in sshd_conf quella principale dei www
Match User sftp_develope_reporting
ChrootDirectory /var/www/
AllowTCPForwarding no
X11Forwarding no
ForceCommand internal-sftp
chiaramente ora il buco di sicurezza è enorme! perchè con l'utente sftp_develope_reporting vedo tutto il contenuto di /var/www senza poter scrivere per fortuna.

come faccio a fare in modo che connettendomi in sftp finisca nella home dir dell'utente e non possa risalire le cartelle???
LorenzoGaruti
Prode Principiante
Messaggi: 72
Iscrizione: martedì 17 aprile 2012, 23:23
Contatti:

Re: sftp - Write failed: Broken pipe

Messaggio da LorenzoGaruti »

Ciao,

puoi fare in questo modo:

nel file /etc/ssh/sshd_conf inserisci

Codice: Seleziona tutto

Match Group webdevel
        ChrootDirectory /var/www/site1
        ForceCommand internal-sftp

Match Group webauthors
        ChrootDirectory /var/www/site1/htdocs
        ForceCommand internal-sftp
Ovviamente devi prima creare gli utenti e assegnarli al gruppo, in questo esempio webdevel e webauthors

Puoi anche limitare l'accesso per ip in questo modo:

Codice: Seleziona tutto

Match Group sftp-only, Address 192.0.43.10
        AllowTCPForwarding no
        X11Forwarding no
        ForceCommand internal-sftp
        ChrootDirectory  /home/servers/

Match Group sftp-only, Address *,!192.0.43.10
        DenyGroups sftp-only
Lorenzo
Scrivi risposta

Ritorna a “Ubuntu su server”

Chi c’è in linea

Visualizzano questa sezione: 0 utenti iscritti e 1 ospite