Skip to content

SFTP Upload tool using Go Exec with Bash/Scp/Sshpass

Notifications You must be signed in to change notification settings

Gurenax/go-sftp-upload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go SFTP Upload

Uploads files to your SFTP server using scp (Secure copy) and sshpass (SSH password provider)


Use Case

Sometimes we have to work on old school pipelines where we can only use sftp to update source files instead of the modern git pipelines that we are used to.
Such an example is uploading wordpress files in which some providers do not provide you access to ssh authentication via rsa keys.
My method will provide you with an alternative to simply use a .env file where you can store your credentials.



Setup Environment Variables

Your .env file should contain values for

USERNAME=
PASSWORD=
SERVER=
SRC=
DEST=

SRC is the local directory/files you wish to upload.
DEST is the remote directory where you wish to upload the local directory/files.
USERNAME, PASSWORD and SERVER should be self-explanatory once you have your sftp credentials.



Install sshpass, Build and Run the App

sshpass will allow us to execute scp without being prompted for a password.

Mac OS

brew install esolitos/ipa/sshpass
go build
./go-sftp-upload

Ubuntu

apt-get install sshpass
go build
./go-sftp-upload

About

SFTP Upload tool using Go Exec with Bash/Scp/Sshpass

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages