Skip to content

How to setup a SFTP server on CentOS

What is SFTP?

SFTP, is the acronym for SSH File Transfer Protocol, or Secure File Transfer Protocol, is a protocol packaged with SSH that works in a similar way as FTP but over a secure connection. The advantage is the ability to leverage a secure connection to transfer files. In almost all cases, SFTP is preferable to FTP because of its underlying security features and ability to piggy-back on an SSH connection.

FTP is an insecure protocol that shouldn’t be used.

Enable PasswordAuthentication in the sshd config file

Backup the current sshd_config

# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.orig

Change it to READ-ONLY to ensure it don’t get overwritten

# chmod a-w /etc/ssh/sshd_config.orig
# vim /etc/ssh/sshd_config

Find the line with the phrase PasswordAuthentication and make it read:

PasswordAuthentication yes

Save your new sshd_config file and then restart the host machine’s ssh service:

# service sshd restart

Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]

Connect to your host and login to your user account

To open an SFTP shell terminal as on the host machine, open a Terminal on your client machine and enter the following command, replacing with your host machine’s IP address hostname:

# sftp <username>@<hostname>
Connected to host.
sftp>