Search code examples
gitsshftpsftpgit-ftp

How do I use sftp on git-ftp client?


I'm trying to use jenkins to automate an sftp upload and replace so that a folder on a sftp server is equal to the git repository. This is using sftp hosted on an openshift running nginx that only supports ftp using an ssh key which I've already generated using their rhc client. I have been able to connect easily to sftp using filezilla using instructions on https://blog.openshift.com/using-filezilla-and-sftp-on-windows-with-openshift/.

I found the most useful and time efficiency would be using a tool called git-ftp.

The steps are pretty forward for ftp using a username, password, and ftp server domain. I'm struggling getting it to do sftp using my ssh key. Here is a site that I found with the best documentation for commands to use. Reference: http://manpages.ubuntu.com/manpages/trusty/man1/git-ftp.1.html.

I was following this guide to get the Jenkins automation setup https://www.savjee.be/2016/02/Use-Jenkins-and-git-ftp-to-deploy-website-to-shared-webhosting/. However, this doesn't show the command to use sftp.

I used https://tohin.wordpress.com/2014/02/11/git-and-sftp/ to try a few different commands without much luck.

Supposedly this works with ftp only giving username, password, and ftp server:

git ftp init --user USERNAME --passwd PASSWORD ftp://YOUR-FTP-SERVER-ADDRESS/path/to/website/

I've adjusted mine to be:

git ftp init -u <openshiftsshtoken> --sftp-key ~/.ssh/id_rsa  sftp://YOUR-FTP-SERVER-ADDRESS/app-root/data/html/<foldertouploadto> 

But it's throwing me some errors.

I want to do a git ftp push after initializing it and making sure the sftp works. E.g.

git ftp push -u <openshiftsshtoken> --sftp-key ~/.ssh/id_rsa  sftp://YOUR-FTP-SERVER-ADDRESS/app-root/data/html/<foldertouploadto>

Could someone point out the errors that I have?


Solution

  • can you try entering sftp protocol as well as port:22 as

    git ftp init --user USERNAME --passwd PASSWORD sftp://domain.com:22/public_html/path/to/website/