1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# create sftp group and user with nologin
$ groupadd sftp
$ useradd -s /sbin/nologin -g sftp sftp
$ passwd sftp
# type and confirm password
# create directory of sftp
$ mkdir -p /data/sftp/share
# change owner of sftp directory
$ chown sftp:sftp /data/sftp/share
# change sftp father directory owner
$ chown root:sftp /data/sftp
# change sftp father directory mod
$ chmod 750 /data/sftp
# configuration of sshd
cat >> /etc/ssh/sshd_config <<EOF
Match User sftp
ForceCommand internal-sftp
PasswordAuthentication yes
ChrootDirectory /data/sftp
AllowTcpForwarding no
X11Forwarding no
EOF
# restart sshd
$ systemctl restart sshd
|