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

New Post: Connection Sharing between SSH SCP and SFTP

$
0
0
In addition to using the SshClient to create the session, I have modified Session.cs as follows,

Session.cs
public Session(ConnectionInfo connectionInfo)
{
    this.ConnectionInfo = connectionInfo;
    //this.ClientVersion = string.Format(CultureInfo.CurrentCulture, "SSH-2.0-Renci.SshNet.SshClient.{0}", this.GetType().Assembly.GetName().Version);this.ClientVersion = string.Format(CultureInfo.CurrentCulture, "SSH-2.0-Renci.SshNet.SshClient.0.0.1");
}
Which meant the test program could look like this,

TestProgram.cs
using(var session = new Session(new PasswordConnectionInfo(host, username, password)))
{
    session.Connect();
    var scpClient = new ScpClient(session);
    scpClient.Uploading += scpClient_Uploading;
    Console.WriteLine("SCP connect? " + scpClient.IsConnected);
    FileInfo fileInfo = new FileInfo(@"C:\mybin\temp.exe");
    scpClient.Upload(fileInfo, "/home/temp/test/temp.exe");


    scpClient = new ScpClient(session);

    scpClient.Uploading += scpClient_Uploading;
    Console.WriteLine("SCP connect? " + scpClient.IsConnected);
    fileInfo = new FileInfo(@"C:\mybin\temp.exe");
    scpClient.Upload(fileInfo, "/home/temp/test/temp2.exe");
}

Viewing all articles
Browse latest Browse all 1729

Trending Articles



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