[email protected]

learn – code – share

Create sftp user in linux


How to create sftp users in linux.

1) open ssh_config in /etc/ssh/
find and comment this line by adding #
#Subsystem      sftp    /usr/libexec/openssh/sftp-server
and add this line.
Subsystem sftp internal-sftp

2) and add this lines at the end of the file.

Match Group sftponly
ChrootDirectory %h
ForceCommand internal-sftp
X11Forwarding no
AllowTcpForwarding no

and save this file and restart the sshd.

3) Create the user and assign to the directory you want to access from sftp.

create a user geekuser and assign to folder geekatlab in /var/www/html
useradd -d /var/www/html/geekatlab -s /bin/false -G sftponly geekuser
and set the password for user geekuser
passwd geekuser
create a directory folder in geekatlab
mkdir /var/www/html/geekatlab/folder
set the root access to this folder geekatlab
chown root /var/www/html/geekatlab
and change permission to this folder geekatlab
chmod 755 /var/www/html/geekatlab
set the user geekuser to access this folder 'folder'
chown ansargeek /var/www/html/geekatlab/folder
change the permisson to this folder 'folder' to read and write
chmod 755 /var/www/html/geekatlab/folder

all done now, try accessing this folder from any sftp client using user geekuser.

any issues comment below…



Leave a Reply

Your email address will not be published. Required fields are marked *