first, directly create
1. Create a user
Useradd test2
2. Set User password
passwd test2
3, modify the login file directory and only allow access to a directory
modifying/etc/ssh/sshd_config files
#Subsystem sftp /usr/libexec/openssh/sftp-server
#这行指定使用sftp服务使用系统自带的internal-sftp
Subsystem SFTP internal-sftp
#这行用来匹配用户
Match user test1
#用chroot将用户的根目录指定到/usr/local/sftp so that users can only/usr/local/ SFTP activities
chrootdirectory /usr/local/sftp
Match User test2# set two accounts
chrootdirectory/home/aa
x11forwarding no
allowtcpforwarding no
Forcecommand internal-sftp #指定sftp命令
4. See if you are logged in
Sftp-oport=22 test2:192.168.2.1
Special attention:
The/usr/local/sftp directory belongs to root. Ensure directory permissions 755 or 750
Second, FTP creation
Yum-y Install vsftpd #通过yum来安装vsftpd
Chkconfig vsftpd on # #设置为开机启动
Vi/etc/vsftpd/vsftpd.conf #设置配置文件
Anonymous_enable=yes #设置是否允许匿名用户登录
Local_enable=yes #设置是否允许本地用户登录
Local_root=/home #设置本地用户的根目录
Write_enable=yes #是否允许用户有写权限
local_umask=022 #设置本地用户创建文件时的umask值
Anon_upload_enable=yes #设置是否允许匿名用户上传文件
Anon_other_write_enable=yes #设置匿名用户是否有修改的权限
Anon_world_readable_only=yes #当为YES时, the other people in the file must have Read permission to allow anonymous users to download, the only person for FTP and read permission is not able to download, must be other people have read permissions, to allow download
Download_enbale=yes #是否允许下载
Chown_upload=yes #设置匿名用户上传文件后修改文件的所有者
Chown_username=ftpuser #与上面选项连用, indicating that the modified owner is Ftpuser
Ascii_upload_enable=yes #设置是否允许使用ASCII模式上传文件
Ascii_download_enable=yes #设置是否允许用ASCII模式下载文件
Chroot_local_user=yes #设置是否锁定本地用户在自己的主目录中, (cannot CD to parent directory or sibling directory after login)
Chroot_list_enable=yes #设置是否将用户锁定在自己的主目录中
Chroot_list_file=/etc/vsftpd/chroot_list #定义哪些用户将会锁定在自己的主目录中
Userlist_enable=yes #当为YES时表示由userlist_file文件中指定的用户才能登录ftp服务器
Userlist_file=/etc/vsftpd/user_list #当userlist_enable为YES时才生效
Service vsftpd Restart #重启vsftpd
The useradd-d/home/www-m/home/www user ##-d directory Specifies the directory of the head of household, and if this directory does not exist, the home directory can be created using the-M option.
passwd User Name # #设置密码
This configuration completes .....
Setting up Firewalls
Vi/etc/sysconfig/iptables-config
Modify
iptables_modules= "Ip_conntrack_ftp"
Open 21 ports
Vi/etc/sysconfig/iptables
Add
-A input-m State--state new-m tcp-p TCP--dport 21-j
Reboot
If you are not able to upload file permissions at this time, modify SELinux
SELinux is not opened here,
chmod 755/home/www
chown-r FTP user name: root directory