/    Sign up×
Community /Pin to ProfileBookmark

SFTP functions

Hi,

I am developing an application which should be capable of uploading files to several other sites. But in all target sites regular FTP is blocked due to security reasons and so, and only SFTP allowed.

Son in that case I need to handle SFTP functions, instead of regular FTP functions. I tried with php ssh2 functions, but it says functions not defined, so I believe some additional php library might be needed. I checked OpenSSL is available in server.

The following is the (sample) code I used.

[code=php]<?php
$connection = ssh2_connect(‘shell.example.com’, 22);
ssh2_auth_password($connection, ‘username’, ‘password’);

$sftp = ssh2_sftp($connection);

$stream = fopen(“ssh2.sftp://$sftp/path/to/file”, ‘r’);
?>
[/code]

It ends prematurely with ssh2_connect as it doesnt recognize function ssh2_connect()

Can someone please guide me for what I need to look for further to make SFTP functions working..

Also, can anyone suggest me an alternative file transfer approach..

Thanks and Best Regards

Indunil

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 04.2009 — How about [url=http://www.php.net/ftp_ssl_connect]ftp_ssl_connect[/url]()?
Copy linkTweet thisAlerts:
@GUIRauthorNov 04.2009 — when tried to connect via ftp_ssl_connect() server refuses connect request (Port 990)..
Copy linkTweet thisAlerts:
@withmanyNov 28.2009 — ftp_ssl_connect() is for FTPS - not for SFTP. For SFTP, try phpseclib:

http://phpseclib.sourceforge.net/
×

Success!

Help @GUIR spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...