how i automatically connet to host

Advertisement

x3group
Joined:
Posts:
2

how i automatically connet to host

            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


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?

Reply with quote

Advertisement

x3group
Joined:
Posts:
2

Re: how i automatically connet to host

martin wrote:

Please read FAQ:
https://winscp.net/eng/docs/faq_hostkey

If that does not help, come back.

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

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
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

Reply with quote

martin
Site Admin
martin avatar

Re: how i automatically connet to host

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.

Reply with quote

Advertisement

You can post new topics in this forum