Skip to content

Latest commit

 

History

History
41 lines (35 loc) · 1.19 KB

README.md

File metadata and controls

41 lines (35 loc) · 1.19 KB

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