Created | Updated | Maintainer |
---|---|---|
2024-07-27 14:01:27 +0530 |
2024-11-02 19:47:44 +0530 |
Ibrar Ansari |
π¨ Please note: This image is designed for educational and testing purposes π π§ͺ ONLY! It is NOT SUITABLE for production environments! π«
This Docker image is built on Ubuntu 22.04 and comes pre-installed with an SSH server, enabling seamless creation of SSH/SFTP-accessible containers. You can effortlessly configure access using SSH keys or by utilizing a default username and password.
ssh-keygen -t rsa -f ~/.ssh/sftp_id_rsa_key -b 4096 -C "This is used for sftp" -N ""
ls -alsh ~/.ssh/
docker pull ibraransaridocker/sftp-server-docker:latest
container_name=sftp_server_1
sftp_user=ibrar_ansari
sftp_pass=your_secure_password
sftp_port=2023
container_image=ibraransaridocker/sftp-server-docker:latest
key_path=~/.ssh/sftp_id_rsa_key.pub
mount_path=/ansari
docker run -itd --name=$container_name -p $sftp_port:22 -e SSH_USERNAME=$sftp_user -e PASSWORD=$sftp_pass -e AUTHORIZED_KEYS="$(cat $key_path)" -v $mount_path:/home/$ssh_user/$mount_path $container_image
Note:- Mounted path will be available under /home/{your_user}/mount_path.
hostname=$(hostname -I | awk '{print $1}')
ssh -i ~/.ssh/sftp_id_rsa_key -p $sftp_port $sftp_user@$hostname
ssh -p $sftp_port $sftp_user@$hostname
sftp <SFTP_USER>@<HOST_IP> -P <PORT>
sftp -P <PORT> -i <PRIVATE_KEY_PATH> <SFTP_USER>@<HOST_IP>
sftp -P <PORT> -oIdentityFile=<PRIVATE_KEY_PATH> <SFTP_USER>@<HOST_IP>
# Create file and assign private key to connect sftp
nano ~/.ssh/config.sftp
Host work
Host <HOST_IP>
User <SFTP_USER>
IdentityFile <PRIVATE_KEY_PATH>
AddKeysToAgent yes
Port <PORT>
# Connect it
sftp -F <PRIVATE_KEY_PATH> <HOST_IP>
Host: sftp://<Your_Host_IP>
Username: Value of sftp_user variable.
Password: Value of sftp_pass variable.
Port: Value of sftp_port variable.
Note:- Mounted path will be available under /home/{your_user}/mount_path.