Docker image with Python + SSH server
5.3K
This container provides the base Python container with a SSH server preinstalled that can be used to connect to the Python interpreter and upload files remotely, i.e. using PyCharm.
By default, a non-root user, created on the Dockerfile, is used for normal operations.
Is recommended to connect SSH using this non-root user, using the username pythonssh and the password sshpass by default.
docker run -d -p 2222:22 --name pythonssh davidlor/python-ssh
-p 2222:22 if you want to change the exposed port on the host machine (2222 to other prefered port)--name "pythonssh" if you wantIf required, root user can be connected through SSH. However, you must set root password manually, following these steps:
docker exec -it -u root pythonssh bash (replace pythonssh with the container name or ID)echo "PermitRootLogin yes" >> /etc/ssh/sshd_configservice ssh restartpasswd and you will be asked for a new password for the user rootexit when done to quit the containerMountpoints are defined on Dockerfile, so volumes will be automatically created if you do not define them.
/home/pythonssh/.ssh (being pythonssh the username of the non-root account)/etc/sshNotice that the latest Python executable is located at /usr/local/bin/python. You must input this route i.e. in PyCharm.
Usage instructions for PyCharm
You can build your own image using this repository. This can be useful for changing the username/password or building for other platforms.
git clone https://github.com/Pythoneiro/Dockerized-Python-SSH.git
docker build -t "local/python-ssh" --build-arg USERNAME=pythonssh --build-arg USERPASS=sshpass Dockerized-Python-SSH
local/python-ssh by your custom desired image namepythonssh by your custom desired usernamesshpass by your custom desired user password/var/log/auth.logContent type
Image
Digest
Size
358.9 MB
Last updated
over 7 years ago
docker pull davidlor/python-ssh