#maltyxx/sshd
Easy to use SSH and SFTP (SSH File Transfer Protocol) server with OpenSSH. This is an automated build linked with the debian repository.
- Define users as command arguments, STDIN
(syntax:
user:pass[:e][:uid[:gid]]...
).- You must set custom UID for your users if you want them to make changes to your mounted volumes with permissions matching your host filesystem.
- Mount volumes in user's home folder.
- The users are chrooted to their home directory, so you must mount the volumes in separate directories inside the user's home directory (/home/user/mounted-directory).
docker run \
-v /share:/home/user/share \
-p 2222:22 -d maltyxx/sshd \
user:password:1001:1001
sshd:
image: maltyxx/sshd
volumes:
- /share:/home/user/share
ports:
- "2222:22"
command: user:password:1001:1001
Add :e
behind password to mark it as encrypted.
Tip: you can use makepasswd to generate encrypted passwords:
echo -n "password" | makepasswd --crypt-md5 --clearfrom -
docker run \
-v /share:/home/user/share \
-p 2222:22 -d maltyxx/sshd \
"user:password:e:1001:1001 user2:password2:e:1002:1002"
Tip: Remplace in the password encrypted $
with $$
.
sshd:
image: maltyxx/sshd
volumes:
- /share:/home/user/share
ports:
- "2222:22"
command: "user:password:e:1001:1001 user2:password2:e:1002:1002"
/ssh/sshd-users.conf:
user:password:e:1001:1001
user2:password2:e:1002:1002
docker run \
-v /ssh:/etc/ssh:ro \
-v /share:/home/user/share \
-p 2222:22 -d maltyxx/sshd \
"user:password:e:1001:1001 user2:password2:e:1002:1002"
sshd:
image: maltyxx/sshd
volumes:
- /ssh:/etc/ssh:ro
- /share:/home/user/share
ports:
- "2222:22"
Mount all public keys in the user's .ssh/keys/
folder. All keys are automatically
appended to .ssh/authorized_keys
.
docker run \
-v /host/id_rsa.pub:/home/user1/.ssh/keys/id_rsa.pub:ro \
-v /host/id_other.pub:/home/user2/.ssh/keys/id_other.pub:ro \
-v /host/share1:/home/user1/share \
-v /host/share2:/home/user2/share \
-p 2222:22 -d maltyxx/sshd \
user::1000
The OpenSSH server runs by default on port 22, and in this example, we are
forwarding the container's port 22 to the host's port 2222. To log in with an
OpenSSH client, run: sftp -P 2222 user@<host-ip>
or ssh -p 2222 user@<host-ip>
or scp -p 2222 user@<host-ip>
.