I. Use the sftp-server provided by openssh
Data can be encrypted and transmitted using sftp. After openssh-server is enabled, sftp-server is enabled by default.
Configuration file/etc/ssh/sshd_config
Modify: Cancel comments.
# Subsystem sftp/usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp
Add:
Match User username X11Forwarding no AllowTcpForwarding no ForceCommand internal-sftp ChrootDirectory /home/sftp
See https://wiki.archlinux.org/index.php/SFTP_chroot
Ii. Install vsftp in Ubuntu/Debian
1. Update the software source
First you need to update the system software source, convenient tool: http://help.aliyun.com/manual? Spm = 0.0.0.0.zJ3dBU & helpId = 1692
2. Install vsftp
Use the apt-get command to install vsftp
# Apt-get install vsftpd-y
3. Add an ftp account and Directory
First check the location of nologin, usually under/usr/sbin/nologin or/sbin/nologin.
Use the following command to create an account. The command specifies/alidata/www/wwwroot as the Home Directory of user pwftp. You can define the account name and directory by yourself:
# Useradd-d/alidata/www/wwwroot-s/sbin/nologin pwftp
Modify the account password:
# Passwd pwftp
Modify the permission of a specified directory
# Chown-R pwftp. pwftp/alidata/www/wwwroot
4. Configure vsftp
To edit the vsftp configuration file, run the following command:
# Vi/etc/vsftpd. conf
Change "anonymous_enable = YES" in the configuration file to "anonymous_enable = NO"
Cancel the annotator before the following Configuration:
Local_enable = YES
Write_enable = YES
Chroot_local_user = YES
Chroot_list_enable = YES
Chroot_list_file =/etc/vsftpd. chroot_list
Save and exit
Edit the/etc/vsftpd. chroot_list file, add the ftp account name, save and exit.
5. Modify shell configuration
Vi edit/etc/shells. If the file does not contain/usr/sbin/nologin or/sbin/nologin (depending on the current system configuration), append it
6. Restart the vsftp service and test logon.
Run the following command to start the vsftp service:
# Service vsftpd restart
Then, use the account pwftp to test whether ftp can be logged on. The directory is/alidata/www/wwwroot.
Refer:
Http://blog.csdn.net/jimyjimang/article/details/7454617
Http://yhf8377.blog.163.com/blog/static/176860177201210217219800/