https://github.com/meibraransari/sftp-server-docker
๐ SFTP with key and password base authentication
https://github.com/meibraransari/sftp-server-docker
sftp sftp-access sftp-client sftp-deploy sftp-download sftp-server sftp-upload sftp-user
Last synced: 3 months ago
JSON representation
๐ SFTP with key and password base authentication
- Host: GitHub
- URL: https://github.com/meibraransari/sftp-server-docker
- Owner: meibraransari
- Created: 2024-07-30T05:14:14.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-11-02T14:20:42.000Z (7 months ago)
- Last Synced: 2024-12-30T20:15:18.904Z (5 months ago)
- Topics: sftp, sftp-access, sftp-client, sftp-deploy, sftp-download, sftp-server, sftp-upload, sftp-user
- Homepage:
- Size: 111 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
Created: 2024-07-27T14:01:27+05:30
Updated: 2024-11-02T19:47:44+05:30
Maintainer: Ibrar Ansari
---
๐ข๐ข๐ข Attention all Docker ๐ณ Beginners & Professionals! ๐ฏ# ๐ป Unlock the power of SFTP with this Ubuntu image, perfect for testing and development! ๐ ๏ธ
## ๐จ 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.
## ๐ฌ Video Demonstration
[](https://youtu.be/P6ialwyqIJg?si=kJFAEoxPH_dwn46A)## Step 1: Create Authentication SSH-Keygen Keys.
```
ssh-keygen -t rsa -f ~/.ssh/sftp_id_rsa_key -b 4096 -C "This is used for sftp" -N ""
ls -alsh ~/.ssh/
```
## Step 2: Pull docker image
```
docker pull ibraransaridocker/sftp-server-docker:latest
```
## Step 3: Set variables to run the docker container.
### Change ๐ variables(containername, username, password & port) according to your need.
```
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
```
## Step 4: Run docker container.
```
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.## Step 5: Test SSH connection
### Get Node IP:
```
hostname=$(hostname -I | awk '{print $1}')
```### Pem Key Method:
```
ssh -i ~/.ssh/sftp_id_rsa_key -p $sftp_port $sftp_user@$hostname
```
### Password Method:
```
ssh -p $sftp_port $sftp_user@$hostname
```## Step 6: Test SFTP Connection
### Test SFTP connection with password method:
```
sftp @ -P
```
### Test SFTP connection with key method:
```
sftp -P -i @
```
### # If the -i option is not available, you can use the -o option with a syntax like::
```
sftp -P -oIdentityFile= @
```
### Connection file method:
```
# Create file and assign private key to connect sftp
nano ~/.ssh/config.sftp
Host work
Host
User
IdentityFile
AddKeysToAgent yes
Port# Connect it
sftp -F
```### Using FileZilla
```
Host: sftp://
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.
```### ๐ผ Connect with me ๐๐ ๐
- ๐ฅ [**Youtube**](https://www.youtube.com/@DevOpsinAction?sub_confirmation=1)
- โ [**Blog**](https://ibraransari.blogspot.com/)
- ๐ผ [**LinkedIn**](https://www.linkedin.com/in/ansariibrar/)
- ๐จโ๐ป [**Github**](https://github.com/meibraransari?tab=repositories)
- ๐ฌ [**Telegram**](https://t.me/DevOpsinActionTelegram)
- ๐ณ [**Docker**](https://hub.docker.com/u/ibraransaridocker)