在Linux上为SCP和SFTP添加Curl支持 [英] Adding Support for SCP and SFTP for Curl on Linux

查看:366
本文介绍了在Linux上为SCP和SFTP添加Curl支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在拼命尝试在CentOS机器上添加对Surl的SFTP和SCP支持。我在这里找到了类似于解决方案的东西:

I've been been desperately trying to add SFTP and SCP support for Curl on my CentOS box. I found something resembling a solution here:

http://andrewberls.com/blog/post/adding-sftp-support-to-curl

我遵循了以下步骤但发现尝试通过SCP和SFTP两者获取文件时,一旦找到文件,连接就会挂起。我无法解决此问题,也找不到替代解决方案。

I followed these steps but found that when attempting to get a file via both SCP and SFTP, the connection hangs once the file has been found. I cannot fix this and cannot find an alternative solution.

我必须在工作中使用Curl,因此无法使用其他lib。有没有人设法在Curl上成功添加对SCP和SFTP的支持?我有一个测试服务器设置和其他协议,例如FTP可以正常工作。

I have to use Curl for a job at work and therefore cannot use another lib. Has anyone managed to successfully add support for SCP and SFTP on Curl? I have a test server setup and other protocols such as FTP work as expected.

任何帮助将不胜感激!

预先感谢
彼得

Thanks in advance, Peter

推荐答案

尽管Curl 支持,支持不会自动包含在默认软件包中。

Although Curl does support SFTP, support isn't automatically included in the default package.

此网站: http://andrewberls.com/blog/post/adding-sftp-support-to-curl 提供的详细信息有助于我添加对SFTP的必需支持。由于该网站对我而言无法100%正常工作,因此我在下面概述了采取的不同步骤。

This website: http://andrewberls.com/blog/post/adding-sftp-support-to-curl provided the details which helped me add the required support for SFTP. As the site didn't work 100% for me, I've outlined the different steps taken below.

手动下载libssh2对我不起作用,所以我使用了yum安装两个软件包:

Manually downloading libssh2 didn't work for me so I used yum to install the two packages:

yum install libssh2 libssh2-devel

,然后按照第二步配置Curl以使用上述库进行安装

and then followed step two configuring Curl to install using the above libraries

最后一步是重新启动sshd :

The final step was to restart sshd:

service sshd restart

有。通过运行

curl -V

我最初进行测试时,Curl抱怨密钥身份验证问题,但是您可以强制Curl使用任何身份验证进行连接:

When I initially tested, Curl complained about key authentication issues, but you can force Curl to use any authentication to connect:

curl --anyauth sftp://user:passwd@127.0.0.1/directory -o Test.txt

这将轮流支持不同的身份验证方法,并让您使用登录凭据。

This will round robin the different supported authentication methods and let you use you login credentials instead.

我希望这有助于减轻试图实现相同目标的人们的其他头痛。

I hope this helps alleviate any other headaches for people trying to achieve the same.

这篇关于在Linux上为SCP和SFTP添加Curl支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆