简体   繁体   English

如何在git-ftp客户端上使用sftp?

[英]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. 我正在尝试使用jenkins自动执行sftp上传和替换,以便sftp服务器上的文件夹等于git存储库。 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. 这是使用在运行nginx的openshift上托管的sftp,该ng仅支持使用我已经使用其rhc客户端生成的ssh密钥进行的ftp。 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/ . 我已经能够按照https://blog.openshift.com/using-filezilla-and-sftp-on-windows-with-openshift/上的说明使用filezilla轻松连接到sftp。

I found the most useful and time efficiency would be using a tool called git-ftp. 我发现最有用和省时的方法是使用工具git-ftp。

The steps are pretty forward for ftp using a username, password, and ftp server domain. 对于使用用户名,密码和ftp服务器域的ftp,这些步骤是相当不错的。 I'm struggling getting it to do sftp using my ssh key. 我正在努力使用我的ssh密钥使其执行sftp。 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 . 参考: 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/ . 我正在按照本指南进行操作以获取Jenkins自动化设置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. 但是,这并未显示使用sftp的命令。

I used https://tohin.wordpress.com/2014/02/11/git-and-sftp/ to try a few different commands without much luck. 我使用https://tohin.wordpress.com/2014/02/11/git-and-sftp/尝试了一些不同的命令,但运气不佳。

Supposedly this works with ftp only giving username, password, and ftp server: 假设这与ftp一起使用,仅提供用户名,密码和ftp服务器:

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. 我要在初始化并确保sftp正常工作后执行git ftp push。 Eg 例如

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? 有人可以指出我的错误吗?

There have been several issues with using SFTP with Git-ftp in the past. 过去,将SFTP与Git-ftp一起使用存在多个问题。 You may face one or several of them. 您可能会面对其中的一个或多个。

  1. You need to provide the SSH private key with the --key option. 您需要为SSH私钥提供--key选项。 You are using a different option. 您正在使用其他选项。 Also make sure that you have a public key as well. 还要确保您也有一个公共密钥。

  2. SFTP assumes absolute paths on the server by default. 默认情况下,SFTP假定服务器上的绝对路径。 If /app-root is not in your server's root directory, but in your user's home directory, then try the URL sftp://YOUR-FTP-SERVER-ADDRESS/~/app-root/... . 如果/app-root不在服务器的根目录中,而是在用户的主目录中,请尝试使用URL sftp://YOUR-FTP-SERVER-ADDRESS/~/app-root/... I added ~/ . 我加了~/

  3. And last, if you don't have the server's fingerprint in you known hosts file in the same way as Curl would expect it, then you either need to add it or use the --insecure flag. 最后,如果您没有在已知主机文件中以Curl期望的方式包含服务器的指纹,则您需要添加它或使用--insecure标志。

Finally, here as an example from the current manual : 最后,以当前手册中的示例为例:

git ftp init -u "john" --key "$HOME/.ssh/id_rsa" "sftp://example.com/~/public_html"

您可以尝试输入sftp protocol以及port:22吗?

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

首先尝试--vv参数显示确切错误如何?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM