CentOS 7 Configuring SFTP

More and more start FTP client software supports SSH protocol to upload and download files, this agreement is SFTP.

There are two main advantages of SFTP, one does not need to configure an FTP server; and second, the SSH protocol is secure data transfers, uploads and downloads are encrypted.

Here are the next most common way to configure CentOS Linux server systems SFTP on 7!

A, sftp installation

Step 1: Create sftp service user groups, creating sftp service root directory:

groupadd sftp 
owner # directory and the parent directory (owner) must by root, and not more than 755, directory group is preferably set to SFTP 
chown -R & lt the root / var / SFTP 
the chmod -R & lt 755 / var / SFTP

Step 2: Create sftp service users:

# Add a user parameter -s / sbin / nologin prevent users from the command line login 
useradd -g SFTP -d / Home / SFTP / Silent -s / sbin / nologin Silent

Step 3: Add user password for the sftp service

passwd silent

Step Four: Configure the sshd_config:

Vim / etc / SSH / the sshd_config 

comment out the following line: 
the Subsystem SFTP     / usr / libexec / OpenSSH / SFTP-Server

In the last sshd_config adding the following lines:

Subsystem sftp internal-sftp
Match Group sftp
    ChrootDirectory /home/sftp/%u
    X11Forwarding no
    AllowTcpForwarding no
    ForceCommand internal-sftp

Note: Here we must note, be sure to put the above code Finally, because of the need to "UseDNS no" back

 Step five: Restart sshd:

systemctl restart sshd

Now you can connect properly, but there may be a problem that can not be uploaded, so we need to set the write permissions:

chown root -R /var/sftp/silent
chmod -R 755 /var/sftp/silent

Two, sftp simple operation

test

sftp silent@127.0.0.1
silent@127.0.0.1's password: 

 

Guess you like

Origin www.cnblogs.com/yyy-blog/p/11130302.html