This repository contains the necessary files to deploy a secure SFTP server using Docker. The setup includes volume mounting for persistent storage, key-based authentication for enhanced security, and customizable SSH configurations.
- Docker installed on your machine.
- Basic understanding of Docker and SFTP.
- Git is also required to clone the repository.
- Basic knowledge of command-line operations.
Generate SSH Key: If you do not already have an SSH key pair, you can generate one using the following command:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f $HOME/.ssh/docker_rsa
Ensure your private key (~/.ssh/docker_rsa) is kept secure with the appropriate permissions:
chmod 600 ~/.ssh/docker_rsa
Load your SSH key into the SSH agent by running:
ssh-add ~/.ssh/docker_rsa
git clone https://github.com/tshenolo/docker-sftp-server-with-sshkey.git
Change your current working directory to the newly cloned repository:
cd docker-sftp-server-with-sshkey
To ensure SSH key-based authentication for your SFTP server, place your SSH public key into the working directory:
cp $HOME/.ssh/docker_rsa.pub .
docker build -t my-sftp-server .
To run your SFTP server container without data persistence, you might use a command like this:
docker run -d --name my_sftp_container -p 2222:22 my-sftp-server
To ensure that uploaded files are not lost when the container stops or is removed, you should persist data by mapping a directory from your host machine to a directory inside the container
docker run -d -v /local/sftp/upload:/home/sftpuser/sftp/upload --name my_sftp_container -p 2222:22 my-sftp-server
Connect to your SFTP server using:
sftp -oPort=2222 sftpuser@localhost
This project simplifies the deployment of a secure SFTP server using Docker. By leveraging Docker's capabilities, you can ensure data persistence, enhance security, and customize configurations to suit your needs.
This project is licensed under the MIT License - see the LICENSE file for details.
- ⭐ Give this repo a ⭐ star ⭐ at the top of the page
- 🐦 Follow me on X
- 📺 Subscribe to my Youtube channel