Sftp on linux build service

Original link: https://www.cnblogs.com/yanduanduan/p/9046723.html

The difference sftp and ftp

FTP is a file transfer protocol, usually in order to facilitate data sharing. Comprising a plurality of FTP servers and FTP client. FTP client via FTP protocol to download resources on the server. The SFTP protocol is encrypted on the basis of the data on the FTP, the data transmission such that the relatively more secure. But this security is based on the expense of efficiency, meaning that SFTP transfer efficiency is lower than FTP.

Build sftp service:

Environment: centos7.2_x64

He began to build:

1. Create sftp group: groupadd sftp

 

View command group information: cat /etc.group

 

 

 

 

 

Creating a user mysftp sftp sftp and added to the group created, and modify the user's password mysftp

useradd -g sftp -s /bin/false mysftp  

passwd mysftp 

 

 

New / data / sftp / mysftp directory, and assign it to the user's home directory group mysftp

mkdir -p /data/sftp/mysftp  

usermod -d /data/sftp/mysftp mysftp

 

 

Edit the configuration file / etc / ssh / sshd_config, vi / etc / ssh / sshd_config

The following symbols # Comment out by

# Subsystem      sftp    /usr/libexec/openssh/sftp-server  

And add the following lines to the file and then save the final surface

Subsystem       sftp    internal-sftp    

Match Group sftp    

ChrootDirectory /data/sftp/%u    

ForceCommand    internal-sftp    

AllowTcpForwarding no    

X11Forwarding no  

 

 

Set Chroot directory permissions

chown root:sftp /data/sftp/mysftp  

chmod 755 /data/sftp/mysftp

 

 

Create a new directory for stp mysftp user to upload files, the directory owner to mysftp all groups as sftp, the owner has write access to all groups no write permission

mkdir /data/sftp/mysftp/upload  

chown mysftp:sftp /data/sftp/mysftp/upload  

chmod 755 /data/sftp/mysftp/upload  

 

 Selinux close and restart sshd service, and then test

 

 Verify, sftp username @ip address on other servers

 

Guess you like

Origin www.cnblogs.com/wqzn/p/11611415.html