深度阅读

How to configure SFTP server on Linux?

作者
作者
2023年08月22日
更新时间
11.86 分钟
阅读时间
0
阅读量

To configure an SFTP server on Linux, you can follow these general steps:

  1. Install the SSH server software.
  2. Create the necessary groups and users for SFTP access.
  3. Configure the SSH server to allow SFTP access and configure the chroot directory for the SFTP users.
  4. Restart the SSH server to apply the changes.

The specific commands and configuration files you’ll need to modify depend on the Linux distribution you’re using. Here’s an example using Ubuntu:

  1. Install openssh-server:
sudo apt-get install openssh-server
  1. Create a new group and user that can be used to login with SFTP:
sudo groupadd sftpusers
sudo useradd -g sftpusers -d /incoming -s /bin/false sftpuser
  1. Edit the SSH configuration file at /etc/ssh/sshd_config to include the following lines:
Subsystem sftp internal-sftp
Match group sftpusers
ChrootDirectory /home/%u
ForceCommand internal-sftp
X11Forwarding no
AllowTcpForwarding no
  1. Restart the SSH server to apply the changes:
sudo service ssh restart

Now you should be able to use an SFTP client to connect to the server using the user “sftpuser” and the chroot directory will be set to /home/sftpuser.

相关标签

博客作者

热爱技术,乐于分享,持续学习。专注于Web开发、系统架构设计和人工智能领域。