CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
SFTP issue

 



zatlas1
Novice

Jun 4, 2013, 12:19 PM

Post #1 of 8 (1245 views)
SFTP issue Can't Post

Hi all

I do


Code
      

$ftp = Net::SFTP::Foreign->new( host=>$host, port => $ftpport ,
password => $ftppwd,
user => $ftpuser,
more => [-o => 'StrictHostKeyChecking no']
);
if (!$ftp)
{
$logger->error( "ERROR: Unable to connect to $host using secure FTP " . $ftp->error . "\n");
}



$host contains $ftpuser@$ftpserver, $ftpport contains 22 (and it is correct) , $ftppwd contains the correct password and $ftpuser is the correct user. Yet, what I get is:

ssh: servername:22: Name or service not known

Note that this is not in the logger (log4perl) but in stderr. $ftp is defined and I continue to the next line as if nothing had happened



What am I doing wrong?


FishMonger
Veteran / Moderator

Jun 4, 2013, 12:38 PM

Post #2 of 8 (1242 views)
Re: [zatlas1] SFTP issue [In reply to] Can't Post

Do you have the strict and warnings pragmas loaded?

Can you show us how you're assigning $host?

Have you used Data::Dumper to dump out $host to verify that it holds exactly what you expect?

Are you able to make the ssh connection from the command line using the same credentials?

Enable verbose:

Code
more => ['-v', -o => 'StrictHostKeyChecking no']


Change:

Code
if (!$ftp)

To:

Code
if ($ftp->error)



zatlas1
Novice

Jun 4, 2013, 1:13 PM

Post #3 of 8 (1238 views)
Re: [FishMonger] SFTP issue [In reply to] Can't Post

Thank you

I did alll the suggestions

Yes, my host is correct myftpuser@myftpserver

and this time an improvement, a message from the logger:

242 ERROR: Unable to connect to myftpuser@myftpserver:22 using secure FTP SSH slave exited unexpectedly with error code 255

Here is what I get from the -v option:

OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: Applying options for *

ssh: myftpserver:22: Name or service not known

2013/06/04 16:00:08 ERROR 242 ERROR: Unable to connect to myftpuser@myftpserver:22 using secure FTP SSH slave exited unexpectedly with error code 255

A quick search on the internet did not help.

When I connect using WinSCP with same credentials and port 22 it works fine

I still cannot figure it out

Thanks

ZA


FishMonger
Veteran / Moderator

Jun 4, 2013, 1:22 PM

Post #4 of 8 (1234 views)
Re: [zatlas1] SFTP issue [In reply to] Can't Post


Quote
Yes, my host is correct myftpuser@myftpserver


I would not expect that to work.

Try using just the hostname (or FQDN) of the server and let the module handle passing the username.


zatlas1
Novice

Jun 4, 2013, 1:29 PM

Post #5 of 8 (1231 views)
Re: [FishMonger] SFTP issue [In reply to] Can't Post

changed this line:


Code
$ftp = Net::SFTP::Foreign->new( host=>$ftpserver, port => $ftpport ,



$ftpserver is the correct name as it was used to create the $host.

No changes in the output... same problem:

OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: Applying options for *

ssh: myftpserver:22: Name or service not known

2013/06/04 16:23:45 ERROR 242 ERROR: Unable to connect to myftpuser@myftpserver:22 using secure FTP SSH slave exited unexpectedly with error code 255

Thank you

ZA


zatlas1
Novice

Jun 4, 2013, 1:35 PM

Post #6 of 8 (1228 views)
Re: [zatlas1] SFTP issue [In reply to] Can't Post

I think I hve found my mistake... please wait


FishMonger
Veteran / Moderator

Jun 4, 2013, 1:39 PM

Post #7 of 8 (1227 views)
Re: [zatlas1] SFTP issue [In reply to] Can't Post


Quote
Name or service not known


When I get that error, the problem always came down to dns not resolving the hostname by its self. Are you able to ping the hostname? Try the FQDN or IP address.


zatlas1
Novice

Jun 4, 2013, 1:48 PM

Post #8 of 8 (1225 views)
Re: [FishMonger] SFTP issue [In reply to] Can't Post

I appericiate your help... it lead me to the correct answer

I had a command that added ':22' to the end of the server name. Once removed, the thing works fine

ZA

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives