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:
/etc/ssh/sshd_config).SFTP is built into OpenSSH, so you only need to configure it properly.
If OpenSSH is not already installed, run the following command to install it:
sudo yum install openssh-server -y
Start the SSH service and enable it to launch at boot:
sudo systemctl start sshd
sudo systemctl enable sshd
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:
Subsystem sftp internal-sftp (this tells SSH to use the built-in SFTP server).sftpusers) and chroot them to their home directories:Match Group sftpusers
ChrootDirectory /home/%u
ForceCommand internal-sftp
X11Forwarding no
AllowTcpForwarding no
Replace %u with the username (or use %h for the home directory).PermitRootLogin no to prevent root logins via SSH/SFTP.Save the file and exit (Ctrl+O, Enter, Ctrl+X).
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
To use FileZilla as a client on CentOS, install it via the package manager or download the RPM package.
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
Start FileZilla from the application menu or terminal:
filezilla
Use FileZilla’s Site Manager to set up a new SFTP connection to your CentOS server.
Ctrl+S).Fill in the following fields:
192.168.1.100).22 (default SFTP port; change if you configured a custom port in /etc/ssh/sshd_config).sftpuser).Click Connect. If this is your first time connecting, FileZilla will prompt you to accept the server’s SSH fingerprint—click OK to proceed.
sudo systemctl status sshd).sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
Once connected, you’ll see two panels:
Ctrl+P to run SFTP commands (e.g., ls, cd, pwd).ssh-keygen) and copy the public key to the CentOS server (ssh-copy-id sftpuser@server_ip)./etc/ssh/sshd_config).By following these steps, you can securely transfer files between your local machine and a CentOS server using FileZilla and SFTP.