centos

FileZilla在CentOS上如何使用SFTP

小樊
46
2025-10-08 21:28:58
栏目: 智能运维

Prerequisites for Using FileZilla with SFTP on CentOS
Before using FileZilla to connect to a CentOS server via SFTP, ensure the following prerequisites are met:


Step 1: Install and Configure SFTP Server on CentOS

SFTP is built into OpenSSH, so you only need to configure it properly.

1.1 Install OpenSSH Server

If OpenSSH is not already installed, run the following command to install it:

sudo yum install openssh-server -y

1.2 Start and Enable SSH Service

Start the SSH service and enable it to launch at boot:

sudo systemctl start sshd
sudo systemctl enable sshd

1.3 Configure SFTP in SSH Config File

Edit the SSH configuration file (/etc/ssh/sshd_config) to restrict SFTP access and enable the SFTP subsystem:

sudo nano /etc/ssh/sshd_config

Make the following changes:

Save the file and exit (Ctrl+O, Enter, Ctrl+X).

1.4 Create SFTP Users and Set Permissions

Create a dedicated SFTP user group and add users to it:

sudo groupadd sftpusers
sudo useradd -m -g sftpusers -s /bin/false sftpuser  # -s /bin/false prevents SSH login
sudo passwd sftpuser  # Set a strong password

Set correct directory permissions for the chroot environment:

sudo chown root:root /home/sftpuser  # Chroot directory must be owned by root
sudo chmod 755 /home/sftpuser        # Allow read/execute for others
sudo mkdir -p /home/sftpuser/uploads # Create a subdirectory for file uploads
sudo chown sftpuser:sftpusers /home/sftpuser/uploads  # Allow user to write to this directory

Restart the SSH service to apply changes:

sudo systemctl restart sshd

Step 2: Install FileZilla on CentOS

To use FileZilla as a client on CentOS, install it via the package manager or download the RPM package.

2.1 Install via Yum (Recommended)

Run the following commands to install FileZilla:

sudo yum install epel-release -y  # Enable EPEL repository (if not already enabled)
sudo yum install filezilla -y

2.2 Launch FileZilla

Start FileZilla from the application menu or terminal:

filezilla

Step 3: Configure FileZilla for SFTP Connection

Use FileZilla’s Site Manager to set up a new SFTP connection to your CentOS server.

3.1 Open Site Manager

3.2 Enter Connection Details

Fill in the following fields:

3.3 Save and Connect

Click Connect. If this is your first time connecting, FileZilla will prompt you to accept the server’s SSH fingerprint—click OK to proceed.


Step 4: Use FileZilla to Transfer Files

Once connected, you’ll see two panels:

Basic File Operations

Advanced Tips


Security Best Practices

By following these steps, you can securely transfer files between your local machine and a CentOS server using FileZilla and SFTP.

0
看了该问题的人还看了