How to restict a user to use another directory?
Step 1
Create a directory with following command
mkdir /sftp-test
mkdir /sftp-test/sftp
then create a user and group
groupadd usersftp
useradd -g usersftp-d /sftp-test -s /sbin/nologin sftpuser
Step 2
Edit the sshd_config file to allow the user to access perticular directory.
vi /etc/ssh/sshd_config
add the following lines and # the following
Subsystem sftp /usr/libexec/openssh/sftp-server
#Subsystem sftp /usr/libexec/openssh/sftp-server
add the following
Subsystem sftp internal-sftp
Match Group exchange
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
Step 3
Now we need to set the permissionas follows
chown root:root /sftp-test
chown sftpuser:root /sftp-test/sftp
now restart the sshd and check it will work 100%
service sshd restart
Step 1
Create a directory with following command
mkdir /sftp-test
mkdir /sftp-test/sftp
then create a user and group
groupadd usersftp
useradd -g usersftp-d /sftp-test -s /sbin/nologin sftpuser
Step 2
Edit the sshd_config file to allow the user to access perticular directory.
vi /etc/ssh/sshd_config
add the following lines and # the following
Subsystem sftp /usr/libexec/openssh/sftp-server
#Subsystem sftp /usr/libexec/openssh/sftp-server
add the following
Subsystem sftp internal-sftp
Match Group exchange
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
Step 3
Now we need to set the permissionas follows
chown root:root /sftp-test
chown sftpuser:root /sftp-test/sftp
now restart the sshd and check it will work 100%
service sshd restart
No comments:
Post a Comment