CentOS6.5 to add sftp uploaded users

Source: Internet
Author: User
Tags chmod mkdir

#创建sftp组

Groupadd SFTP
#创建一个用户zjhp
Useradd-g sftp-s/bin/false ZJHP
#设置zjhp用户的密码
passwd ZJHP
#创建一个sftp的上传目录
Mkdir/usr/local/sftp
#修改用户dsideal所在的目录
usermod-d/usr/local/sftp ZJHP

#配置sshd_config

Vi/etc/ssh/sshd_config
#找到如下这行, and comment out
#Subsystem Sftp/usr/libexec/openssh/sftp-server
#添加如下几行
subsystem sftp internal-sftp #这行指定使用sftp服务使用系统自带的internal-sftp
Match User ZJHP #这行用来匹配用户
Chrootdirectory/usr/local/sftp #用chroot将用户的根目录指定到/usr/local/sftp so that users can only move under/USR/LOCAL/SFTP
Allowtcpforwarding No
Forcecommand internal-sftp #指定sftp命令
#保存退出

#设定Chroot目录权限
Chown-r root:root/usr/local/sftp
chmod 755/usr/local/sftp/

#建立SFTP用户登入后可写入的目录
Mkdir/usr/local/sftp/zjhp
Chown-r zjhp:sftp/usr/local/sftp/zjhp/
chmod 755/usr/local/sftp/zjhp/

#重启sshd服务
Service sshd Restart

#关闭SElinux
Vi/etc/sysconfig/selinux
#找到如下这行
Selinux=enforcing
#修改为
Selinux=disabled
#保存退出

#重启服务器
Reboot

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.