Linux Build SFTP Server

Source: Internet
Author: User
Tags connection reset

Transferred from: http://blog.csdn.net/superswordsman/article/details/49331539

Recently work needs to use the SFTP server, is the network of various methods, especially the issue of permission settings to get dizzy, now will build their own process summed up a bit, sorting out a simple way for everyone to reference.

On the 1th, add the SFTP user and set the root directory: useradd-d/home/sftp-s/sbin/nologin Sftpuser

2nd Walk, Change Password: Execute passwd sftpuser, then enter the password 2 times

On the 3rd step, modify the configuration file, execute Vi/etc/ssh/sshd_config, add the following information inside:

Subsystem sftp internal-sftp

Match User Sftpuser
#X11Forwarding No
#AllowTcpForwarding No
#ForceCommand internal-sftp

4th Walk, set access permissions for the root directory: chmod 777/home/sftp (optional)

On the 5th, restart the sshd process to make the configuration effective: service sshd restart

At this point, the SFTP server is set up, using the command SFTP [email protected] Landing, landing success explained the success of the building.

Note: If CHROOTDIRECTORY/HOME/SFTP is added to the configuration file, the owner and the owning group of the root directory must be root, at which point the directory permissions should be set:

Chown root:root/home/sftp

chmod 755/home/sftp

At this time only the user root has write access to the/HOME/SFTP directory, and the use of Sftpuser this user login is not write permission, it is necessary to create a new folder in the/home/sftp/directory, and give Sftpuser read and write permissions, This will complete the SFTP operation.

This shows that after adding chrootdirectory in the configuration file, you need to pay special attention to the permissions issue.

Problems:

1, sftp login times wrong:

Connecting to 10.66.2.111 ...
/etc/ssh/ssh_config:line 60:bad Configuration Option:usedns
/etc/ssh/ssh_config:terminating, 1 Bad configuration options
Couldn ' t read packet:connection reset by peer

The problem is caused by DNS resolution to see if there is Usedns no in the client's profile/etc/ssh/ssh_config, and if so, comment out the line.

2, SFTP connection is particularly slow, and warning: reverse mapping checking getaddrinfo for Bogon [10.91.0.227] failed-possible break-in attempt!

Possible cause: Locate the configuration file/etc/ssh/sshd_config on the SFTP server and change gssapiauthentication Yes to Gssapiauthentication No.

Linux Build SFTP Server

Related Article

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.