sftp

Latest response

Once configured the cage in the file sshd_config
Subsystem sftp internal-sftp
Match Group sftponly
ChrootDirectory %h
AllowTcpForwarding no
ForceCommand internal-sftp

and
home/user root:root rwx r-x r-x
home/user root:root rwx r-x r-x
home/user/input user:sftponly rwx r-x r-x

passwd
user:x:502:501:user:/home/onosftp:/sbin/nologin
group
sftponly:x:501:user

sftp user@xxx.xxx.xxx

sftp>ls
Couldn't get handle: Permission denied
sftp>

Help

Responses

We have here this ls

#

ls -la /home/USER/

total 36
drwxr-xr-x 5 root USER 4096 Jul 8 10:30 .
drwxr-xr-x 18 root root 4096 Jun 26 2014 ..
...
drwx------ 2 USER USER 4096 Jul 10 13:50 .ssh
drwxr-xr-x 3 USER USER 4096 Jul 10 21:58 upload

#

You see the . group is USER.
Cheers

[root@lnx-ono-01 home]# ls -al /home/onosftp
total 12
drwxr-xr-x. 3 root root 4096 ene 1 14:06 .
drwxr-xr-x. 7 root sftponly 4096 ene 1 13:48 ..
drwxr-xr-x. 2 onosftp sftponly 4096 ene 1 14:01 ficheros

Do you have read my comment and do you have understand it?

understant,
I'm Spanish and my English is very bad, you can enlighten me a little

Hi Juan,

(I am neither English, nor Spanish. Still hope to be able to enlighten you)

My English text, below you can find a Google translation in Spanish

Aleksander asks whether you understand what he wrote.
You have to check the user name and group name owning the subdirectory.
He suggest to make them the user name and group name "user" like you mentioned in this discussion.

So not root:sftponly.

=========================================================================

Google translation in Spanish: Hope this helps a little

Aleksander pregunta si usted entiende lo que él escribió.
Usted tiene que comprobar el nombre de usuario y el nombre del grupo propietario del subdirectorio.

Se sugiere para hacerlos el nombre de usuario y nombre de grupo "usuario", como usted ha mencionado en este debate.

Kind regards,

Jan Gerrit Kootstra

chgrp sftponly /home/onosftp
and then test again

I have the same problema
onosftp@172.19.21.15's password:
sftp> ls
Couldn't get handle: Permission denied
sftp>

[root@lnx-ono-01 ~]# ls -al /home/onosftp
total 20
drwxr-xr-x. 4 root sftponly 4096 ene 2 13:22 .
drwxr-xr-x. 6 root root 4096 ene 2 13:24 ..
-rw-------. 1 onosftp sftponly 38 ene 2 13:22 .bash_history
drwxr-xr-x. 2 onosftp sftponly 4096 ene 1 14:01 ficheros
drwx------. 2 onosftp sftponly 4096 ene 2 13:22 .ssh

Hm ok.

please can you try the following.

shell1: $(which sshd) -ddd -p 4711
shell2: sftp -P 4711 -vvv onosftp@172.19.21.15

and post the output of both shells.

sftp -P 4711 -vvv onosftp@172.19.21.15

Attaching to 4711...
exec: 4711: No such file or directory
Couldn't read packet: Connection reset by peer

If Selinux is enable on your linux box , then for Chroot SFTP you need to write SELiux rule “setsebool -P ssh_chroot_rw_homedirs on”.

This was my problem; Thank you very much for your attention

Hi Juan,

Thanks for sharing the solution.
Just to complete the situation: What RHEL release do you use? (cat /etc/redhat-release)

Kind regards,

Jan Gerrit Kootstra

I use RHEL reléase
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.6 (Santiago)
# uname -a
2.6.32-504.1.3.el6.x86_64 #1 SMP Fri Oct 31 11:37:10 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux

same problem, it doesn't work :(

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.