Topic "how i automatically connet to host"

Author Message
x3group
[View user's profile]

Joined: 2013-03-28
Posts: 4
Code:
            this.SessionOptions = new SessionOptions();
            this.SessionOptions.HostName = HostName;
            this.SessionOptions.UserName = UserName;
            this.SessionOptions.PortNumber = PortNumber;
            this.SessionOptions.Password = Password;
            this.SessionOptions.Protocol = Protocol;
            this.SessionOptions.SshHostKeyFingerprint = SshHostKeyFingerprint;

            try
            {
                m_Session.Open(this.SessionOptions);
            }
            catch (Exception exp)
            {
            }


if i set correctly SshHostKeyFingerprint all work
if SshHostKeyFingerprint empty i get exception "SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.HostKey is not set."

but for gui winscp get correctly SshHostKeyFingerprint automatically


Quote:
Using SSH protocol version 2
We claim version: SSH-2.0-WinSCP_release_5.1.4
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-1
Verifying host key rsa2 0x23,0xb9c35c82f30eaaf274a76...
Asking user:
The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is.

The server's rsa2 key fingerprint is:
ssh-rsa 1024 55:aa:e9:fa:b0:4c:66:e0:ea:cc:4f:34:bf:e2:45:f0

If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel.

Continue connecting and add host key to the cache? ()
Host key fingerprint is:
ssh-rsa 1024 55:aa:e9:fa:b0:4c:66:e0:ea:cc:4f:34:bf:e2:45:f0
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption



how i get correctly SshHostKeyFingerprint automatically from c# code?
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Please read FAQ:
https://winscp.net/eng/docs/faq_hostkey

If that does not help, come back.
_________________
Martin Prikryl
x3group
[View user's profile]

Joined: 2013-03-28
Posts: 4
prikryl wrote:
Please read FAQ:
https://winscp.net/eng/docs/faq_hostkey

If that does not help, come back.


Quote:
Quote:
You should get SSH hostkey fingerprint along with your credentials from the server administrator.


Quote:
In a real world, most administrators do not provide the hostkey fingerprint.
In order to obtain the fingerprint yourself you need to connect to the server.



how i can run
Quote:
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-1

in c# code?


I connect on 300+ server to periodically download logs
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Not sure what you mean.

If you want to give up on any security and just blidlessly connect to any server, you can use SessionOptions.GiveUpSecurityAndAcceptAnySshHostKey. This is available only in 5.2 beta.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License