Uploads files to your SFTP server using scp (Secure copy)
and sshpass (SSH password provider)
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.
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.
sshpass
will allow us to execute scp
without being prompted for a password.
brew install esolitos/ipa/sshpass
go build
./go-sftp-upload
apt-get install sshpass
go build
./go-sftp-upload