How to launch a SFTP server?
by n00b_noob from LinuxQuestions.org on (#58064)
Hello,
I'm using CentOS 8 and I want to disable vsftpd and use SFTP instead of it.
I'm a beginner and found a tutorial like below and I need experts opinions about this tutorial. I want my user just see a specific folder:
Code:The first thing we must do is create a directory that will house our FTP data:
# mkdir -p /data
# chmod 701 /data
Create the SFTP group and user:
# groupadd sftp_users
# useradd -g sftp_users -d /upload -s /sbin/nologin USERNAME
# passwd USERNAME
Create the new user SFTP directory
Now we're going to create an upload directory, specific to the new user, and then give the directory the proper permissions.
# mkdir -p /data/USERNAME/upload
# chown -R root:sftp_users /data/USERNAME
# chown -R USERNAME:sftp_users /data/USERNAME/upload
Configure sshd:
# nano /etc/ssh/sshd_config
At the bottom of that file, add the following:
Match Group sftp_users
ChrootDirectory /data/%u
ForceCommand internal-sftpMy problem with this tutorial is that it created a directory, but I want my SFTP user see "/var/www/WP" directory when he\she logged to server.
The permission of directory is as below:
Code:$ ls -lZ /var/www/
total 268
-rw-r--r--. 1 root root system_u:object_r:usr_t:s0 266455 Oct 5 2012 apache_pb.svg.bak
drwxr-xr-x. 2 root root system_u:object_r:httpd_sys_script_exec_t:s0 6 Jun 9 00:46 cgi-bin
drwxr-xr-x. 2 root root system_u:object_r:httpd_sys_rw_content_t:s0 6 Jun 9 00:46 html
drwxrwxr-x. 7 apache apache unconfined_u:object_r:httpd_sys_rw_content_t:s0 4096 Sep 3 12:33 wpIf I add my user to "apache" group then I don't need to create an extra group and below commands?
Code:# chown -R root:sftp_users /data/USERNAME
# chown -R USERNAME:sftp_users /data/USERNAME/uploadThank you.


I'm using CentOS 8 and I want to disable vsftpd and use SFTP instead of it.
I'm a beginner and found a tutorial like below and I need experts opinions about this tutorial. I want my user just see a specific folder:
Code:The first thing we must do is create a directory that will house our FTP data:
# mkdir -p /data
# chmod 701 /data
Create the SFTP group and user:
# groupadd sftp_users
# useradd -g sftp_users -d /upload -s /sbin/nologin USERNAME
# passwd USERNAME
Create the new user SFTP directory
Now we're going to create an upload directory, specific to the new user, and then give the directory the proper permissions.
# mkdir -p /data/USERNAME/upload
# chown -R root:sftp_users /data/USERNAME
# chown -R USERNAME:sftp_users /data/USERNAME/upload
Configure sshd:
# nano /etc/ssh/sshd_config
At the bottom of that file, add the following:
Match Group sftp_users
ChrootDirectory /data/%u
ForceCommand internal-sftpMy problem with this tutorial is that it created a directory, but I want my SFTP user see "/var/www/WP" directory when he\she logged to server.
The permission of directory is as below:
Code:$ ls -lZ /var/www/
total 268
-rw-r--r--. 1 root root system_u:object_r:usr_t:s0 266455 Oct 5 2012 apache_pb.svg.bak
drwxr-xr-x. 2 root root system_u:object_r:httpd_sys_script_exec_t:s0 6 Jun 9 00:46 cgi-bin
drwxr-xr-x. 2 root root system_u:object_r:httpd_sys_rw_content_t:s0 6 Jun 9 00:46 html
drwxrwxr-x. 7 apache apache unconfined_u:object_r:httpd_sys_rw_content_t:s0 4096 Sep 3 12:33 wpIf I add my user to "apache" group then I don't need to create an extra group and below commands?
Code:# chown -R root:sftp_users /data/USERNAME
# chown -R USERNAME:sftp_users /data/USERNAME/uploadThank you.