Linux SFTP user creation does not allow users to log on, and connections are only allowed in the established directory to operate

Source: Internet
Author: User

1. Create a user

Groupadd SFTP

2. add user and set as SFTP group

Useradd-g sftp-s/sbin/nologin-m sftp (/sbin/nologin for users who are not allowed to log in to the shell)

3. Set User password

passwd SFTP

4. Create a user directory. and set permissions.

Cd/home

mkdir SFTP

Chown root:sftp SFTP

chmod 755 SFTP

5. Modify the SSH configuration

/etc/ssh/sshd_config

Repair and change Subsystem

Subsystem sftp internal-sftp

6. Add User Configuration in Sshd_config

Match User sftp #限制的用户

X11forwarding No

Allowtcpforwarding No

Forcecommand internal-sftp

Chrootdirectory/home/sftp #用户的根目录

7. Finally restart SSH

/etc/init.d/ssh restart

#END

Linux SFTP user creation does not allow users to log on, and connections are only allowed in the established directory to operate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.