dev-resources.site
for different kinds of informations.
SFTP server in Ubuntu
Published at
2/8/2021
Categories
sftp
sftpserver
Author
Eduardo Issao Ito
How to setup a basic SFTP server in Ubuntu.
Requirements
- No login
- Read and write permissions
- Access only to a base directory
- Default directory should be the base directory
Instalation
Install the sftp server package
sudo apt-get install openssh-server
Create sftp group and user
sudo groupadd sftpgroup
sudo useradd myuser -m -G sftpgroup -s /usr/sbin/nologin
sudo passwd myuser
Prepare base sftp directory
sudo chown root:root /home/myuser
sudo mkdir /home/myuser/data
sudo chown myuser:sftpgroup /home/myuser/data
Configure sftp server
Edit the file /etc/ssh/sshd_config
Comment the following line:
#Subsystem sftp /usr/lib/openssh/sftp-server
Add the folowing lines at the end of the file:
Subsystem sftp internal-sftp
Match group sftpgroup
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp -d /data
Restart the server
sudo service ssh restart
Test
$ sftp myuser@localhost
myuser@localhost's password:
Connected to localhost.
sftp> pwd
Remote working directory: /data
sftp> put test.txt
Uploading test.txt to /data/test.txt
test.txt 100% 0 0.0KB/s 00:00
sftp> ls
test.txt
sftp> quit
Articles
12 articles in total
Resumo Kubernetes
read article
Check for newer versions of dependencies in pom.xml
read article
Changing the JVM in spring-boot:build-image
read article
Changing the base Linux image in spring-boot:build-image
read article
Custom Root CA in spring-boot:build-image
read article
Getting http status in curl
read article
DB2 backup/restore schema
read article
Using MTLS
read article
Convert OpenAPI spec to JSON Schema
read article
Json validation with OpenAPI Schema
read article
SFTP server in Ubuntu
currently reading
Using multiple JMS servers with Spring Boot
read article
Featured ones: