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

New Post: Issue trying to send a command via SSH to VMWare

$
0
0
I'm able to run commands like "who" when testing, but when I try to run something like "services.sh restart" it just hangs. Running it using Putty works fine.

Thanks,
Adrian
var connectionInfo = new KeyboardInteractiveConnectionInfo(host, 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();
                var cmd = ssh.RunCommand("services.sh restart");
                Console.WriteLine(cmd.Result);
                ssh.Disconnect();
            }

Viewing all articles
Browse latest Browse all 1729

Trending Articles



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