![]() |
![]() |
|
|
dotSSH Last Release: 1.0dotSSH is a SSH2 and SFTP3 library designed for the .NET Framework written in 100% managed C#. The power of a hightly secure protocol to transfer files or directories with a remote server, or to run maintenance tasks. Single-threaded SSH libraries are bottlenecks for multi-threaded applications. That's why dotSSH has been designed with multi-threading in mind. It can process several requests simultaneously. That's the only way to use all the power available from your modern computers. Indeed, desktop computers now have dual-cores processor, servers already have several processors for years. Since a thread can be processed by only one virtual processor, if a single-threaded program is executed on a system with four virtuals processors, you would only use one forth of the power. Thanks to dotSSH, you will not have this problem. Features:
Requirements: .NET Framework 1.1, 2.0 or compatible.Online ressources: Trial copy request: Purchase:
You may read more details about our licenses: Licensing: Samples:
SFTP Channel: Listing files: (C#)
SshConnection conn = new SshConnection();
conn.Connect("168.154.12.48", 22, "user", "pass");
SftpChannel chan = conn.OpenSftpChannel();
SftpListing listing = chan.ListContent("/backups/may/");
foreach(SftpFileInfo fi in listing)
{
Console.WriteLine(fi.Path + " " + fi.Size + " " + fi.ModificationDateTime);
}
chan.Close();
conn.Disconnect();
SFTP Channel: Listing files: (VB.NET)
Dim conn As SshConnection = new SshConnection()
conn.Connect("168.154.12.48", 22, "user", "pass")
Dim chan As SftpChannel = conn.OpenSftpChannel()
Dim listing As SftpListing = chan.ListContent("/backups/may/")
For Each fi As SftpFileInfo In listing
Console.WriteLine(fi.Path & " " & fi.Size & " " & fi.ModificationDateTime)
Next
chan.Close()
conn.Disconnect()
SFTP Channel: Recursive directory upload: (C#)
SshConnection conn = new SshConnection();
conn.Connect("168.154.12.48", 22, "user", "pass");
SftpChannel chan = conn.OpenSftpChannel();
chan.UploadDirectory(@"D:\data", @"/backups/may/"); // Uploads the content of D:\data to /backups/may/data
chan.UploadDirectory(@"D:\movies", @"/DVDs"); // Uploads the content of D:\movies to /DVDs
chan.Close();
conn.Disconnect();
SFTP Channel: Recursive directory upload: (VB.NET)
Dim conn As SshConnection = new SshConnection()
conn.Connect("168.154.12.48", 22, "user", "pass")
Dim chan As SftpChannel = conn.OpenSftpChannel()
chan.UploadDirectory("D:\data", "/backups/may/") ' Uploads the content of D:\data to /backups/may/data
chan.UploadDirectory("D:\movies", "/DVDs") ' Uploads the content of D:\movies to /DVDs
chan.Close()
conn.Disconnect()
Execution Channel: Text processing: (C#)
SshConnection conn = new SshConnection();
conn.Connect("168.154.12.48", 22, "user", "pass");
ExecChannel chan = conn.ExecuteRemoteBourneShellCommand("sed 's/fox/cat/g'");
TextWriter wtr = chan.GetStandardInput(System.Text.Encoding.ASCII);
wtr.WriteLine("The quick brown fox jumps over the lazy dog.\n");
wtr.Flush(); // Write data left in the TextWriter to the SSH2 channel
chan.CloseStdIn(); // Send End Of File for standard input (all data is sent)
Console.WriteLine(chan.ReadToEnd(System.Text.Encoding.ASCII));
chan.Close();
conn.Disconnect();
Execution Channel: Text processing: (VB.NET)
Dim conn As SshConnection = new SshConnection()
conn.Connect("168.154.12.48", 22, "user", "pass")
Dim chan As ExecChannel = conn.ExecuteRemoteBourneShellCommand("sed 's/fox/cat/g'")
Dim wtr As TextWriter = chan.GetStandardInput(System.Text.Encoding.ASCII)
wtr.WriteLine("The quick brown fox jumps over the lazy dog." & vbNewLine)
wtr.Flush() ' Write data left in the TextWriter to the SSH2 channel
chan.CloseStdIn() ' Send End Of File for standard input (all data is sent)
Console.WriteLine(chan.ReadToEnd(System.Text.Encoding.ASCII))
chan.Close()
conn.Disconnect()
Execution Channel: Transfer of binary data: (C#)
SshConnection conn = new SshConnection();
conn.Connect("168.154.12.48", 22, "user", "pass");
ExecChannel chan = conn.ExecuteRemoteBourneShellCommand("gzip");
Stream inOut = chan.GetBinaryStream();
Stream comp = new FileStream("C:\\sample.bin.gz", FileMode.Create);
chan.RedirectStdOut(comp); // Redirects standard output to our file
Stream data = new FileStream("C:\\sample.bin", FileMode.Open);
int count;
byte[] buffer = new byte[1024];
while((count = data.Read(buffer, 0, buffer.Length)) > 0)
{
inOut.Write(buffer, 0, count);
}
data.Close();
// First, close standard input to make sure all data is sent.
chan.CloseStdIn();
// Secondly, wait the process to make sure it sent all its output.
chan.WaitForExit();
// Then, close channel to make sure all bufferd data of standard output is written in 'comp'.
chan.Close();
// Finally, you can close the output file.
comp.Close();
conn.Disconnect();
Execution Channel: Transfer of binary data: (VB.NET)
Dim conn As SshConnection = new SshConnection()
conn.Connect("168.154.12.48", 22, "user", "pass")
Dim chan As ExecChannel = conn.ExecuteRemoteBourneShellCommand("gzip")
Dim inOut As Stream = chan.GetBinaryStream()
Dim comp As Stream = new FileStream("C:\sample.bin.gz", FileMode.Create)
chan.RedirectStdOut(comp) ' Redirects standard output to our file
Dim data As Stream = new FileStream("C:\sample.bin", FileMode.Open)
Dim count As Integer
Dim buffer As Byte() = new byte(1024) {}
count = data.Read(buffer, 0, buffer.Length)
While count > 0
inOut.Write(buffer, 0, count)
count = data.Read(buffer, 0, buffer.Length)
End While
data.Close()
' First, close standard input to make sure all data is sent.
chan.CloseStdIn()
' Secondly, wait the process to make sure it sent all its output.
chan.WaitForExit()
' Then, close channel to make sure all bufferd data of standard output is written in 'comp'.
chan.Close()
' Finally, you can close the output file.
comp.Close()
conn.Disconnect()
|
||||||||||||||||||||||
All rights reserved. etive.com (tm) 2000-2008 - Disclaimer