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

New Post: SSH connection issue

$
0
0
Hello

Im a c# newbie, i used the code mentioned above with some modifications.

im trying to SSH into a linux busybox (unify Acces point)
the idea is to do a scheduled restart of the device, once every 24 hours.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Renci.SshNet;
using Renci.SshNet.Common;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string host = "10.150.110.64",
                   username = "admin",
                   password = "pass";
            int    port = 22;

            var connectionInfo = new KeyboardInteractiveConnectionInfo(host, port, username);
            connectionInfo.AuthenticationPrompt += delegate(object sender, AuthenticationPromptEventArgs e)
            {
                foreach (var prompt in e.Prompts)
                {
                    if (prompt.Request.Equals("Password: ",StringComparison.InvariantCultureIgnoreCase))
                    {
                        prompt.Response = password;
                    }
                }



            };

            using (var ssh = new SshClient(connectionInfo))
            {

                ssh.Connect();
                ssh.RunCommand("reboot");
                ssh.RunCommand("exit");

            }

        }
    }
}
when i try to run it. it returns with SshAuthenticationException was unhandled
my thought is that this ssh connection needs to accept the algorithm key when connection to a server first time.

is there any way to do this? or am i all wrong in my assumption?

enlighten me oh great masters ;)

Best Regards
mrjinx

Viewing all articles
Browse latest Browse all 1729

Trending Articles



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