Make sure you are connecting to an SSH or SFTP server

0 votes
asked Jul 7 by jamanga (180 points)

Hi

I checked the previous messages for this error - the server definitely appears to be SFTP. I have been given a hostname, username and privatekey file, however I don't get past the the Connect() method...

Initially it appeared frozen, but this was due to:

Settings.WaitForServerWelcomeMessage = true;

.. now the error is as per the below log:

2020-07-07 13:44:31.183 Opening log file.
2020-07-07 13:44:31.185 INFO FileLogWriter(1)[1] Info: Assembly: Rebex.Common 2019 R1 for .NET 4.0-4.7
2020-07-07 13:44:31.188 INFO FileLogWriter(1)[1] Info: Platform: Windows 6.2.9200 64-bit; CLR: 4.0.30319.42000
2020-07-07 13:44:31.189 DEBUG FileLogWriter(1)[1] Info: Culture: en; Windows-1252
2020-07-07 13:44:35.696 INFO Sftp(1)[1] Info: Connecting to [serverprefix].upload.akamai.com:22 using Sftp.
2020-07-07 13:44:35.697 INFO Sftp(1)[1] Info: Assembly: Rebex.Sftp 2019 R1 for .NET 4.0-4.7
2020-07-07 13:44:35.697 INFO Sftp(1)[1] Info: Platform: Windows 6.2.9200 64-bit; CLR: 4.0.30319.42000
2020-07-07 13:44:35.697 DEBUG Sftp(1)[1] Info: Culture: en; Windows-1252
2020-07-07 13:44:35.711 DEBUG Sftp(1)[1] Proxy: Resolving '[serverprefix].upload.akamai.com'.
2020-07-07 13:44:35.723 DEBUG Sftp(1)[1] Proxy: Connecting to 23.64.137.133:22 (no proxy).
2020-07-07 13:44:35.852 VERBOSE Sftp(1)[1] SSH: Sending data:
0000 |53-53-48-2D-32-2E-30-2D 52-65-62-65-78-53-53-48| SSH-2.0-RebexSSH
0010 |5F-35-2E-30-2E-37-30-32 37-2E-30-0D-0A | _5.0.7027.0..
2020-07-07 13:45:00.179 ERROR Sftp(1)[1] SSH: Rebex.Net.SshException: The connection was closed by the server. Make sure you are connecting to an SSH or SFTP server.
at Rebex.Net.SshSession.nxja()
at Rebex.Net.SshSession.Negotiate()
2020-07-07 13:45:00.183 ERROR Sftp(1)[1] Info: Rebex.Net.SshException: The connection was closed by the server. Make sure you are connecting to an SSH or SFTP server.
at Rebex.Net.SshSession.nxja()
at Rebex.Net.SshSession.Negotiate()
at Rebex.Net.Sftp.mosg.krod(oiok alr, Boolean als)
at Rebex.Net.Sftp.jlvf(String po, Int32 pp, SshParameters pq, oiok pr)

My login code is:

_FtpClient.Connect(hostname); <- exception raised here
if (privateKey != null) {
    _FtpClient.Login(username, privateKey);
} else {
    _FtpClient.Login(username, password);
}

Please let me know if you need any other details.

Applies to: Rebex SFTP
commented Jul 7 by jamanga (180 points)
I should have also mentioned that the SftpException that does get raised takes around 30 seconds to occur.

1 Answer

+1 vote
answered Jul 7 by Lukas Pokorny (111,330 points)

Hi,

According to Akamai's NetStorage User Guide, it looks like the proper host name might be "[serverprefix].sftp.upload.akamai.com" instead of "[serverprefix].upload.akamai.com".

The following example appears to be working fine:

_FtpClient.Connect("nsmediadocs.sftp.upload.akamai.com");

Please try this with your actual [serverprefix] and let me know whether it helps.

commented Jul 7 by jamanga (180 points)
Hi Lukas

Thanks for the response, adding the .sftp within the hosthname did resolve to an IP as well, however it gives back the same exception alas.
commented Jul 7 by Lukas Pokorny (111,330 points)
Does the Connect method succeed if you use "nsmediadocs" for server prefix, or does that fail as well?
commented Jul 8 by jamanga (180 points)
No - same response.  I timed it this time, it's actually ~60 seconds until the exception occurs.
I may as well mention, this host is actually: tvsnvod.upload.akamai.com
commented Jul 8 by Lukas Pokorny (111,330 points)
I'm afraid that the most likely explanation is some network issue at your side. It looks like some firewall or router is blocking outgoing connections.
I'm able to establish connection to both tvsnvod.upload.akamai.com:22 and nsmediadocs.sftp.upload.akamai.com:22 without any problem. Our sshcheck.com online tool can connect as well - see https://sshcheck.com/server/tvsnvod.upload.akamai.com/22 for the results.

Are you able to connect to the site using Windows Telnet? Simply executing "telnet tvsnvod.upload.akamai.com 22" from a command prompt should get you connected and display the server's software identification string: "SSH-2.0-Server-VIII-hpn14v11"
commented Jul 9 by jamanga (180 points)
Damn - you were right, apparently the Networking team have locked down external access recently... which was the issue.
Thanks for putting me on the right track.
commented Jul 9 by Lukas Pokorny (111,330 points)
Thanks for letting us know!
...