Bonjour à tous,

Je galère à mettre en place du SFTP avec un chroot...

J'ai suivi les tutos trouvés ici et là, mais j'ai toujours le même problème et je ne sais pas comment débugger

J'ai un dossier /datas/chroot qui est mon dossier racine pour le chroot.

J'ai configuré /etc/ssh/sshd_config de cette façon:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
Port 22
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
UsePrivilegeSeparation yes
KeyRegenerationInterval 3600
ServerKeyBits 768
SyslogFacility LOCAL6
LogLevel INFO
LoginGraceTime 120
PermitRootLogin no
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
X11Forwarding no
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server 
UsePAM yes
Mon fichier /etc/rssh.conf:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
logfacility = LOG_USER
allowsftp
umask = 022
chrootpath = "/datas/chroot"
Contenu et droits de /datas/chroot:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 
ls -alR /datas/chroot/
/datas/chroot/:
total 36
drwxr-x--- 8 root tout_le_monde 4096 juil.  2 10:37 .
drwxr-xr-x 6 root root          4096 juin  29 14:33 ..
drwxr-xr-x 3 root root          4096 juin  29 16:27 datas
drwxr-xr-x 2 root root          4096 juil.  2 10:37 dev
drwxr-xr-x 3 root root          4096 juil.  2 10:37 etc
drwxr-xr-x 3 root root          4096 juil.  2 10:37 lib
drwxr-xr-x 2 root root          4096 juil.  2 10:37 lib64
drwxr-xr-x 4 root root          4096 juil.  2 10:37 usr
 
/datas/chroot/datas:
total 12
drwxr-xr-x 3 root          root          4096 juin  29 16:27 .
drwxr-x--- 8 root          tout_le_monde 4096 juil.  2 10:37 ..
drwxr-xr-x 2 test test 4096 juil.  2 10:00 test
 
/datas/chroot/datas/test:
total 20
drwxr-xr-x 2 test test 4096 juil.  2 10:00 .
drwxr-xr-x 3 root          root          4096 juin  29 16:27 ..
-rw-r--r-- 1 test test  220 juin  29 16:25 .bash_logout
-rw-r--r-- 1 test test 3590 juin  29 16:25 .bashrc
-rw-r--r-- 1 test test  675 juin  29 16:25 .profile
 
/datas/chroot/dev:
total 8
drwxr-xr-x 2 root root          4096 juil.  2 10:37 .
drwxr-x--- 8 root tout_le_monde 4096 juil.  2 10:37 ..
srw-rw-rw- 1 root root             0 juil.  2 09:54 log
crw-rw-rw- 1 root root          1, 3 juil.  2 09:54 null
crw-rw-rw- 1 root root          1, 5 juil.  2 09:54 zero
 
/datas/chroot/etc:
total 76
drwxr-xr-x 3 root root           4096 juil.  2 10:37 .
drwxr-x--- 8 root tout_le_monde  4096 juil.  2 10:37 ..
-rw-r--r-- 1 root root          53157 juil.  2 10:37 ld.so.cache
-rw-r--r-- 1 root root             34 juil.  2 10:37 ld.so.conf
drwxr-xr-x 2 root root           4096 juil.  2 10:37 ld.so.conf.d
-rw-r--r-- 1 root root            475 juil.  2 10:37 nsswitch.conf
-rw-r--r-- 1 root root           1812 juil.  2 10:37 passwd
 
/datas/chroot/etc/ld.so.conf.d:
total 24
drwxr-xr-x 2 root root 4096 juil.  2 10:37 .
drwxr-xr-x 3 root root 4096 juil.  2 10:37 ..
lrwxrwxrwx 1 root root   40 juil.  2 10:37 i386-linux-gnu_GL.conf -> /etc/alternatives/i386-linux-gnu_gl_conf
-rw-r--r-- 1 root root  108 juil.  2 10:37 i686-linux-gnu.conf
-rw-r--r-- 1 root root   44 juil.  2 10:37 libc.conf
-rw-r--r-- 1 root root   68 juil.  2 10:37 x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root   42 juil.  2 10:37 x86_64-linux-gnu_GL.conf -> /etc/alternatives/x86_64-linux-gnu_gl_conf
-rw-r--r-- 1 root root   56 juil.  2 10:37 zz_i386-biarch-compat.conf
 
/datas/chroot/lib:
total 12
drwxr-xr-x 3 root root          4096 juil.  2 10:37 .
drwxr-x--- 8 root tout_le_monde 4096 juil.  2 10:37 ..
drwxr-xr-x 2 root root          4096 juil.  2 10:37 x86_64-linux-gnu
 
/datas/chroot/lib/x86_64-linux-gnu:
total 1772
drwxr-xr-x 2 root root    4096 juil.  2 10:37 .
drwxr-xr-x 3 root root    4096 juil.  2 10:37 ..
-rwxr-xr-x 1 root root 1802936 juil.  2 10:37 libc.so.6
 
/datas/chroot/lib64:
total 156
drwxr-xr-x 2 root root            4096 juil.  2 10:37 .
drwxr-x--- 8 root tout_le_monde   4096 juil.  2 10:37 ..
-rwxr-xr-x 1 root root          149280 juil.  2 10:37 ld-linux-x86-64.so.2
 
/datas/chroot/usr:
total 16
drwxr-xr-x 4 root root          4096 juil.  2 10:37 .
drwxr-x--- 8 root tout_le_monde 4096 juil.  2 10:37 ..
drwxr-xr-x 2 root root          4096 juil.  2 10:37 bin
drwxr-xr-x 4 root root          4096 juil.  2 10:37 lib
 
/datas/chroot/usr/bin:
total 100
drwxr-xr-x 2 root root  4096 juil.  2 10:37 .
drwxr-xr-x 4 root root  4096 juil.  2 10:37 ..
-rwxr-xr-x 1 root root 27096 juil.  2 10:37 rssh
-rwxr-xr-x 1 root root 63552 juil.  2 10:37 scp
 
/datas/chroot/usr/lib:
total 16
drwxr-xr-x 4 root root 4096 juil.  2 10:37 .
drwxr-xr-x 4 root root 4096 juil.  2 10:37 ..
drwxr-xr-x 2 root root 4096 juil.  2 10:37 openssh
drwxr-xr-x 2 root root 4096 juil.  2 10:37 rssh
 
/datas/chroot/usr/lib/openssh:
total 72
drwxr-xr-x 2 root root  4096 juil.  2 10:37 .
drwxr-xr-x 4 root root  4096 juil.  2 10:37 ..
-rwxr-xr-x 1 root root 63552 juil.  2 10:37 sftp-server
 
/datas/chroot/usr/lib/rssh:
total 36
drwxr-xr-x 2 root root  4096 juil.  2 10:37 .
drwxr-xr-x 4 root root  4096 juil.  2 10:37 ..
-rwxr-xr-x 1 root root 27120 juil.  2 10:37 rssh_chroot_helper
Mon /etc/passwd:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
test:x:1011:1012:,,,:/datas/chroot/datas/test:/usr/bin/rssh

Bref, et donc quand j'essaie de me connecter la session se ferme toute seule sans message d'erreur:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
sftp test@monserv
test@monserv's password: 
Connection closed
Et dans /var/log/syslog j'ai:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
Jul  2 10:38:49 monserv sshd[4164]: Accepted password for test from 10.1.220.xxx port 50495 ssh2
Jul  2 10:38:54 monserv sshd[4307]: subsystem request for sftp by user test
Jul  2 10:38:54 monserv rssh[4308]: setting log facility to LOG_USER
Jul  2 10:38:54 monserv rssh[4308]: allowing sftp to all users
Jul  2 10:38:54 monserv rssh[4308]: setting umask to 022
Jul  2 10:38:54 monserv rssh[4308]: chrooting all users to /datas/chroot
Jul  2 10:38:54 monserv rssh[4308]: chroot cmd line: /usr/lib/rssh/rssh_chroot_helper 2 "/usr/lib/openssh/sftp-server"
Jul  2 10:38:54 monserv sshd[4307]: Received disconnect from 10.1.220.xxx: 11: disconnected by user

Est-ce que quelqu'un saurait m'aider? ou au moins m'expliquer comment avec des logs où l'on pourrait voir les erreurs ?

Merci d'avance
Bonne journée,

zobbyzobba