This repository provides a Docker setup for securely transferring files between Windows and Linux (or any Docker host) using an Ubuntu container with SSH enabled. You can use scp (Secure Copy Protocol) to push and pull files through the containerβs SSH server.
- Docker installed on your system
- Basic familiarity with the command line (PowerShell, Bash, etc.)
- A text editor to review or modify the Dockerfile
# Use the official Ubuntu image as the base
FROM ubuntu:latest
# Set environment variables to avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# Update the package list and install necessary packages
RUN apt-get update && \
apt-get install -y \
openssh-server \
nano \
vim \
net-tools \
curl \
wget \
fail2ban && \
mkdir /var/run/sshd && \
echo 'root:root' | chpasswd && \
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
sed -i 's/#PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
# Enable fail2ban service to protect SSH (requires systemd; see notes below)
RUN systemctl enable fail2ban
# Expose the SSH port
EXPOSE 22
# Start SSHD in the foreground
CMD ["/usr/sbin/sshd", "-D"]- Base image:
ubuntu:latest - SSH server: Installed and configured to allow root login with password
- Fail2Ban: Enabled to protect against bruteβforce attacks
- Exposed port:
22for SSH
-
Build the Docker image
docker build -t my_ubuntu_ssh . -
Run the container
docker run -d \ --name scptest \ -p 2222:22 \ my_ubuntu_ssh
- Maps host port 2222 β container port 22
- Root password is set to
root(see Security Notes)
-
Verify SSH is running
docker ps # Should show your scptest container listening on 0.0.0.0:2222->22/tcp
- Root login: Enabled for demonstration. In production, create a nonβroot user with SSH keys.
- Passwords: The root password is
root. Change it in the Dockerfile (echo 'root:<your-password>') or use key-based auth. - Fail2Ban: Requires
systemdto run properly inside container; you may need a workaround or external firewall rules.
From your host machine (Windows PowerShell, Git Bash, or Linux shell):
- Upload a file to the container:
scp -P 2222 path/to/local/file.txt root@localhost:/root/
- Download a file from the container:
scp -P 2222 root@localhost:/root/file.txt path/to/local/destination/
Replace
path/to/...with your actual file paths.
To persist files between container restarts, mount a host directory:
docker run -d \
--name scptest \
-p 2222:22 \
-v /path/on/host:/root/transfer \
my_ubuntu_ssh- Files uploaded to
/root/transferinside the container will live on your host at/path/on/host.
- Stop & remove container:
docker stop scptest docker rm scptest
- Remove image:
docker rmi my_ubuntu_ssh
This project is released under the MIT License. Feel free to use, modify, and distribute!