Setup Test Container sFTP Server
Using atmoz-sftp
Steps:
-
Download the FileZilla Client from the official website.
-
Set Up an SFTP Server:
-
Refer to this image to create and run an SFTP Server container from the docker hub: atmoz-sftp.
-
Generate an SSH key pair: Create a private key sftp_rsa and a public key sftp_rsa.pub. Store them in a directory, e.g., ~/Downloads/sftp/keys.
-
Pull the Docker image, docker pull atmoz/sftp.
-
Choose a hostname: use "foo" for the client and "19" as the port.
- Run the Docker Container:
Use the command below to start the docker container, mount the volumes to transfer the public key to the server, and share files between the localhost and Docker container:
docker run \
-v ~/Downloads/sftp/keys/sftp_rsa.pub:/home/foo/.ssh/keys/sftp_rsa.pub:ro \
-v ~/Downloads/share:/home/foo/share \
-p 19:22 -d atmoz/sftp \
foo::1001
- Configure FileZilla Client:
Start FileZilla Client: Go to File → Site Manager → My Sites (create a name) → General → Set the following:
Protocol: SFTP
Host: localhost
Port: 19
Logon type: Key file
User: foo
Key file: Browse and select the private key sftp_rsa
Click Connect
- Verify Connection:
You should see the message “Status: Directory listing of /share successful" in the FileZilla dashboard. The remote site /share folder should reflect the files from your local ~/Downloads/share folder.
- Troubleshooting:
If you encounter issues, use the following commands to check the status and logs of the Docker container:
docker ps
docker logs <CONTAINER ID>