Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Connecting to OpenSSH server

$
0
0
I have set up an OpenSSH server and try to connect using the following code:
var connectionInfo = new ConnectionInfo(host, 22, username, new PasswordAuthenticationMethod(username, password));
            //var connectionInfo = new ConnectionInfo(host, 22, username, new KeyboardInteractiveAuthenticationMethod(username));
            try
            {
                using (var client = new ScpClient(connectionInfo))
                {
                    client.HostKeyReceived += delegate(object sndr, HostKeyEventArgs ex)
                    {
                        if (ex.FingerPrint.SequenceEqual(new byte[] { 0x2a, 0x08, 0xd5, 0x69, 0xe0, 0x9f, 0xcc, 0xdb, 0x3d, 0xc2, 0x78, 0x06, 0x61, 0xd0, 0xf4, 0xc4 }))
                        {
                            ex.CanTrust = true;
                        }
                        else
                        {
                            ex.CanTrust = false;
                        }
                    };
                    client.Connect();
                    //  Do something here
                    client.Disconnect();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
but I get a "User cannot be authenticated exception. I can login fine with Putty and WinSCP. What could be the problem?

(I'm no SSH expert, or even a novice)

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>