Adding Support for SCP and SFTP for Curl on Linux

≡放荡痞女 提交于 2019-12-08 04:09:05

问题


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

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.

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.

Any help would be greatly appreciated!

Thanks in advance, Peter


回答1:


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

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.

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

yum install libssh2 libssh2-devel

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

The final step was to restart sshd:

service sshd restart

There you have it. Double check that SFTP is on the list of support protocols by running

curl -V

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.



来源:https://stackoverflow.com/questions/25451985/adding-support-for-scp-and-sftp-for-curl-on-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!