Skip to main content
1 of 3
user avatar
user avatar

SFTP server nor working

I'm kinda inexperienced at Linux, so I will just leave here all commands I used, to set up SFTP server on Ubuntu 18.04 Server.

My goal is to create an SFTP server, with the following criteria:

  • All SFTP users are in "sftp_users" group.
  • All users DO NOT have their own folder.
  • All users have access ONLY to 1 common folder (/data/sftp).
  • Anyone of SFTP users can read, write, execute (aka upload, download, delete, etc.) any file in this common folder.

Commands I used to set up a server

apt update
apt install openssh-server
mkdir -p /data/sftp
chmod 701 /data
groupadd sftp_users
useradd -g sftp_users -d /data/sftp -s /sbin/nologin sftptest
passwd sftptest
chown -R root:sftp_users /data/sftp
chown -R sftptest:sftp_users /data/sftp
nano /etc/ssh/sshd_config

Added this lines at the end of file

Match Group sftp_users
ChrootDirectory /data/sftp
ForceCommand internal-sftp

And did

systemctl restart sshd

When I`m trying to connect to the server by SFTP with WinSCP, it gives me the error

Authentication log (see session log for details):
Using username "sftptest".

Authentication failed.

Uploaded session log to Pastebin

user363532