drateR is a simple SFTP (Secure File Transfer Protocol) server implemented in Go. It provides a secure way to upload and download files using the SFTP protocol over SSH.
- Secure File Transfers: Utilizes SSH for encrypted file transfers.
- Basic Authentication: Uses a plain text password stored in an environment variable for authentication.
- Customizable Directory: Configurable directory for storing uploaded files.
- Go 1.16 or higher
- SSH private key for authentication
- Environment variables for configuration
src/
│
├── drateR.go
└── files/
drateR.go
: The main Go script for running the SFTP server.files/
: Directory where uploaded files will be stored.
First, clone the repository to your local machine:
git clone https://github.com/zeusssz/drateR.git
cd drateR/src
Make sure you have the required Go packages installed:
go get github.com/pkg/sftp
go get golang.org/x/crypto/ssh
Generate an SSH key pair if you don't already have one:
ssh-keygen -t rsa -b 2048 -f id_rsa -N ""
id_rsa
: Your private key.id_rsa.pub
: Your public key (not needed in this script but required for SSH setup).
Set the SFTP_PASSWORD
environment variable with your chosen password:
export SFTP_PASSWORD="your_password"
Ensure the privateKeyPath
constant in drateR.go
is set to the path of your private key:
privateKeyPath = "id_rsa" // Path to the private key for authentication
Navigate to the src
directory and run the server:
cd src
go run drateR.go
The server will start listening on port 2022
by default.
You can connect to the SFTP server using any SFTP client. Here are a few examples:
sftp -P 2022 user@<IP_ADDRESS_OF_SERVER>
Replace <IP_ADDRESS_OF_SERVER>
with the IP address of the machine running the SFTP server. Use the password you set in the SFTP_PASSWORD
environment variable when prompted.
-
Download PuTTY from PuTTY Download Page.
-
Open
psftp
and connect:psftp -P 2022 user@<IP_ADDRESS_OF_SERVER>
-
Enter the password when prompted.
- Port: The server listens on port
2022
by default. Modify theport
constant indrateR.go
to change this. - Root Directory: The directory where files are stored is specified by
rootDir
. Change it if needed.
- Failed to Connect: Ensure that the server is running and the port is open. Verify the private key path and permissions.
- Authentication Issues: Double-check the environment variable
SFTP_PASSWORD
for correct password value and spelling.