I created second instances of sshd called sshd-sftponly and using different port (e.g 2222 ) and made all necessary changes in

/etc/rc.d/init.d/sshd-sftponly and /etc/ssh/sshd_config-sftponly

Configuration in my /etc/ssh/sshd_config-sftponly file for SFTP is :

Match group sftponly
    AllowTcpForwarding no
    X11Forwarding no
    ChrootDirectory /srv/h%
    ForceCommand internal-sftp

Created user and group :

#groupadd sftponly
#useradd –g sftponly –d /srv/sftpuser –s /sbin/nologin sftpuser  
#passwd sftp

sshd-sftponly second instances service restarted :

#/etc/init.d/sshd-sftponly restart 

Pemission and ownership :

755 root:root /srv


700 sftpuser:sftponly /srv/sftpuser

Now after connection established of sftp on 2222 port using “ sftpuser” user credential . it’s view full “/” path

I want to access or view only /srv/sftpuser (i.e user home directory )

Note : without disturbing any configuration running for first sshd instances .

Any suggestions?

  • You have got a typo on line ChrootDirectory /srv/h%. It should be ChrootDirectory /srv/%u. Anyway, check for errors you see in log. – Jakuje Jun 8 '16 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.