Add sftp account and restricted directory
Step 1: Add sftp account:
useradd -m -d /data/www/www.xxx.com -s /sbin/nologin -g root user1
Step 2: Set account password: passwd
user1
Step 3: Modify /etc/passwd and set the user level just added to 0
. ---------
for example, user1:x:1001:0::/data/www/www.xxx.com:/sbin/nologin , change the 1001 in the front to 0, and then save.
-------------------------------------
Step 4: Modify /etc/ssh/ sshd_config
-------------------------------------
found Subsystem sftp /usr/lib/openssh Add # in front of /sftp-server, comment the line
and add the following:
Subsystem sftp internal-sftp
Match User user1
ChrootDirectory /data/www/www.xxx.com AllowTcpForwarding
no
X11Forwarding no
ForceCommand internal-sftp
users, repeat the following 3 lines
Match user user2
ForceCommand internal-sftp
ChrootDirectory /home/ftpdir
Find UsePAM yes Add # in front, comment this line
------------------------ --------------
Save after modification.
Step 5: Then restart the ssh service
service ssh restart
Ubuntu adds sftp account and restricted directory
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326587596&siteId=291194637
Recommended
Ranking