Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to build SFTP Service in linux

Shulou Source: shulou.com Published: 2022-06-02 10:49:11 09月12日 Update

It is believed that many inexperienced people have no idea about how to build SFTP service in linux. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

SFTP build process:

1. Create a SFTP group

$groupadd sftp

Information about using the cat / etc/group command group after creation

$cat / etc/group

2. Create a sftp user mysftp and join the created sftp group, and change the password of the mysftp user.

$useradd-g sftp-s / bin/false mysftp $passwd mysftp

3. Create a new / data/sftp/mysftp directory and specify it as the home directory for mysftp group users

$mkdir-p / data/sftp/mysftp $usermod-d / data/sftp/mysftp mysftp # modify the mysftp user's home directory to / data/sftp/mysftp

4. Edit the configuration file / etc/ssh/sshd_config

$vi / etc/ssh/sshd_config

Comment out the following line with the # symbol

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

And add the following lines at the end of the file and then save

Subsystem sftp internal-sftp

Match Group sftp

ChrootDirectory / data/sftp/%u

ForceCommand internal-sftp

AllowTcpForwarding no

X11Forwarding no

5. Set directory permissions

$chown root:sftp / data/sftp/mysftp $chmod 755 / data/sftp/mysftp

6. Create a new directory for sftp user mysftp to upload files. The owner of this directory is mysftp, all groups are sftp, and the owner has write permission. All groups have no write permission.

$mkdir / data/sftp/mysftp/upload $chown mysftp:sftp / data/sftp/mysftp/upload $chmod 755 / data/sftp/mysftp/upload

7. Close selinux and restart the sshd service, and then test

# shut down selinux$setenforce 0setenforce:SELinux is disabled# and restart sshd service $systemctl restart sshd.service

Verify on another server, sftp user name @ ip address

2. Project local path selects the address of the local project. Project name needs to have the same name as the local directory, and Next

3. The remote server address is 10.17.11.251. After filling in the personal account password, you can click Test Connection to test whether the connection is normal. Remember to check the Don't check HTTP connection to server,Next below

4. Select the root directory of the remote server target project, and then click the Project Root above. If the directory does not exist, contact the administrator to create it. Next

5 、 finish

6. The remote SFTP connection has been created.

When synchronizing the project, select the target directory or file, and right-> Deployment- > Upload to..., select the corresponding remote server. You can also use the shortcut key Ctrl+Alt+Shift+X

Check Tools- > Deployment- > Automatic Upload to automatically synchronize the remote server after each local modification and save.

After reading the above, have you mastered how to build SFTP services in linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Services directories users servers selections files contents addresses permissions items passwords owners methods more goals problems synchronization testing helplessness Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Linux Shulou Tech Info vpn Xiaomi