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

New Post: Simple .cshtml example?

$
0
0
Major noob here. I'm trying to write a connection string to run really basic commands and get the output. Can someone just show me the simplest way to do this using Razor view engine (.cshtml)? Below is my sad code:
@using Renci.SshNet.Common;
@using Renci.SshNet.Channels;
@using Renci.SshNet.Compression;
@using Renci.SshNet.Sftp;
@using Renci.SshNet.Security;
@using Renci.SshNet.Messages;

@{
    
using (var sshClient = new SshClient("server", "user", "password"))

{

    var terminal = sshClient.RunCommand("ls -l");

    var output = terminal.Result;

}
    
}
This spits out the following error on the line "var terminal = sshClient.RunCommand("ls -l");": "Exception Details: System.ArgumentNullException: Value cannot be null."

Would someone be able to help me?

Viewing all articles
Browse latest Browse all 1729

Trending Articles



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