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

New Post: Error when I login to a linux server

$
0
0
Hi, this should work for both AIX and Linux:
 _OutErr = "";

        var KeyboardInteractive = new KeyboardInteractiveAuthenticationMethod(_User);
        KeyboardInteractive.AuthenticationPrompt += delegate(Object senderObject, AuthenticationPromptEventArgs eventArgs)
        {
            foreach (var prompt in eventArgs.Prompts)
            {
                if (prompt.Request.Equals("Password: ", StringComparison.InvariantCultureIgnoreCase))
                {
                    prompt.Response = "password";
                }
            }
        };

        var passwordAuthMethod = new PasswordAuthenticationMethod(_User, _Pw));
        var connectionInfo = new ConnectionInfo(_Server, _User, passwordAuthMethod, KeyboardInteractive);
        SshClient sshe = new SshClient(connectionInfo);

        try
        {
            sshe.Connect();
            _Out = sshe.RunCommand(_Cmd);
        }
        catch (Exception eConnect)
        {
            _OutErr = eConnect.Message;
        }
        finally
        {
            sshe.Disconnect();
            sshe.Dispose();
        }

regards
jmueller

Viewing all articles
Browse latest Browse all 1729

Trending Articles



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