Quantcast
Channel: SSH.NET Library
Viewing all 2955 articles
Browse latest View live

New Post: cannot use the Renci.SshNet in a NetduinoPlusApplication

$
0
0
Hi guys!

I am newbie using that framework, but my problem is the following one:

I have created a NetduinoPlusApplication solution in VS 2010, and all my code is well compiled. The warnings and errors are showing when I try to building the solution.
All the warnings referencing to the Renci.SshNet.dll file. For instance:
"The reference to the type "System.Text.StringBuilder" indicate that is defined in 'C:\Program Files (x86)\Microsoft.NET Micro Framework\v4.1\Assemblies\le\mscorlib.dll', but it has not been found"

I have no idea about this warning.
Can someone suggest to me any way to reference the "renci.sshnet.dll" correctly?

Sorry for my English, I am from Argentina.
Thanks you!
Regards.

New Post: SSH.NET vs Tamir SharpSSH

$
0
0
Hello,

I am looking for a halfway decent if strong SSH (and SCP, SFTP) client for .NET 4.0 concerns.

I ran across http://www.tamirgal.com/blog/page/SharpSSH.aspx at first, but it seems that this one has not been maintained or is at end of life. Obvious things like SshBase not being IDisposable come to mind (seems obvious right? call Close on Dispose...). That sort of thing.

Anyway, I installed SSH.NET via NuGet and this seems to run without any problems (yet, knock on wood...).

Curious what others are experiencing with SSH.NET? Obviously no perfect software, but does it basically get the job done? Has enough robustness that it can be useful in a number of use cases?

Thank you...

Regards,

Michael Powell

New Post: SCP copy to a specific folder

$
0
0
Hi,

i'm using 2013.1.27 and i try to copy a file from a windows to a linux machine.
My copy command looks like:
m_Scp.Upload(fi, sTargetDir + fi.Name);
where sTargetDir is "update/". My copied file pops up on the linux machine within directory ~/update/update/.
Looks like a bug.

If i use "./update/" everything works fine.

Thanks - Markus

New Post: Sharing Download/Upload methods in BaseClient

$
0
0
actually i'm writing a clr for download and upload file through ms sql.
Both scp and sftp support upload and download. It could be a good approach to write a virtual method for upload and download in BaseClient. So if i like to switch the protocol, i just need to get the base class and execute download/upload method.

right now, i need something like this.
Boolean isSftp = (transferProtocol.Value.ToLower() == "sftp");
            using (Renci.SshNet.BaseClient ssh = isSftp == true ? 
                (new Renci.SshNet.SftpClient(new Renci.SshNet.PasswordConnectionInfo(server.Value, 22, user.Value, password.Value)) as Renci.SshNet.BaseClient) :
                new Renci.SshNet.ScpClient(new Renci.SshNet.PasswordConnectionInfo(server.Value, 22, user.Value, password.Value))
            )
            {
                ssh.Connect();
                //sftp.ChangeDirectory(System.IO.Path.GetDirectoryName(source.Value));
                //if (sftp.Exists(source.Value) == false)
                //    throw new Exception(String.Concat("File: ", source, " do not exists on the remote server"));
                System.IO.FileStream file = null;
                using (file = System.IO.File.Exists(destination.Value) == false ? System.IO.File.OpenWrite(destination.Value) : System.IO.File.Create(destination.Value))
                {
                    if (isSftp == true)
                        (ssh as Renci.SshNet.SftpClient).DownloadFile(source.Value, file);
                    else
                        (ssh as Renci.SshNet.ScpClient).Download(source.Value, file);
                }
                //delete only if sftp
                if (delete.IsTrue == true && isSftp == true)
                    (ssh as Renci.SshNet.SftpClient).Delete(source.Value);
            }

Created Issue: Remote File exists not working [1574]

$
0
0
I've tried to use sftp.Exists(String) do not work for files. Already tested for file and for directory. Directory work well, but files are not recognized.

New Post: Bad Packet Length Error

$
0
0
Hello everyone and thanks for your help in advance. Completely new to SSH.Net and had created a project for connecting to an SFTP serverdoing the following:
Dim sftpclient As New SftpClient("host", port, "user", "password")
The project worked fine for a few weeks but then began encountering a bad packet length error. In researching, I cam across a few articles suggestingencryption wasthe problem:

http://stackoverflow.com/questions/10886665/how-to-resolve-a-bad-packet-length-error-in-ssh-net

http://sshnet.codeplex.com/discussions/271671

but I amso new to this, I really don'tunderstand what I am doing. Any helpwould be appreciated.

New Post: No such File or Directory

$
0
0
Hello,

First I'd like to say that you have a great product here!

I am working with the latest binary (SshNet 4.0 Binary, 2013.4.7) and still get the scp error: "No such File or Directory" when trying to upload a file using the scp client. My C# code is listed below, but I have tried many variations of of this code based on the forum discussion with the same results. The target directory on linux "/data" is valid. Any suggestions would be greatly appreciated.

Thanks
Jim
    private void SCP_Upload_File()
    {
        try
        {
            string file = "C://temp//test.sh";
            if (!File.Exists(file)) return;

            FileInfo scriptInfo = new FileInfo(file);
            if ( ! scriptInfo.Exists)  return;

            ConnectionInfo connectionInfo = new PasswordConnectionInfo(host, port, user, pw);

            ScpClient scpClient = new ScpClient(connectionInfo);
            scpClient.BufferSize = 8 * 1024;
            scpClient.Connect();

            if (!scpClient.IsConnected)
            {
                return;
            }

            string targetPath = @"/data/test.sh";
            scpClient.Upload(scriptInfo.OpenRead(), targetPath);
            scpClient.Disconnect();
        }
        catch (Exception e)
        {
            lb_Log.Items.Add(e.Message);
        }
    }

New Post: key file formats

$
0
0
Any chance support for a public SSH2 key will be included any time soon?

New Post: No such File or Directory

$
0
0
Any luck with this one? I too am finding the library WONDERFUL! THANK YOU! SSH works like a charm. Now I would like to copy a result that I redirected from the SSH command:
~/command --some_args >~/result.txt
Now via SCP, I say:
//The Configure and Connected are some extensions I cooked up to help it out by convention.
using (var client = new ScpClient(Host, User, Password).Configure().Connected())
{
  using (var fs = new FileStream("local.txt", FileMode.Create, FileAccess.Write, FileShare.Read))
  {
    //TODO: May hook up Downloading event (in fact I am, but for sake of example, the point is moot.
    client.Download("~/result.txt", fs);
    //ScpException: scp: ~/result.txt: No such file or directory
  }
}
However, like my colleague here, getting the same issue. It's there! I checked via Ssh. Is there a trick to making the Scp client work?

I could run the following and pick up the file: scp root@10.10.0.1:~/result.txt local.txt

Regards,

Michael Powell

New Post: No such File or Directory

$
0
0
May be helpful, I ran an experiment with "local.txt" instead of "~/local.txt" and wouldn't you know it, I got the file transferred! Yay!

However, I would expect anything after the ":" in a typical Scp command would be fair game for Download remote file name, but who knew?

Perhaps some documentation around that issue would be a good thing.

HTH

Regards,

Michael Powell

New Post: No such File or Directory

$
0
0
My file upload issue was finally resolved by adding the modified Upload method (redled, Feb 7, 2012) to the ScpClient.cs:
    public void Upload_2(FileInfo fileInfo, string filePath)
    {
        using (var input = new PipeStream())
        using (var channel = this.Session.CreateChannel<ChannelSession>())
        {
            channel.DataReceived += delegate(object sender, Common.ChannelDataEventArgs e)
            {
                input.Write(e.Data, 0, e.Data.Length);
                input.Flush();
            };

            channel.Open();

            //  Send channel command request
            string directoryPath = filePath.Substring(0, filePath.LastIndexOf('/') + 1);
            string filename = filePath.Substring(filePath.LastIndexOf('/') + 1);

            if (String.IsNullOrEmpty(directoryPath))
                channel.SendExecRequest(string.Format("scp -qt {0}", filename));
            else
                channel.SendExecRequest(string.Format("cd {0};", directoryPath) + string.Format("scp -qt {0}", filename));
            this.CheckReturnCode(input);

            this.InternalUpload(channel, input, fileInfo, filename);

            channel.Close();
        }
    }

New Post: No such File or Directory

$
0
0
This is in ScpClient itself? So it is a bug in ScpClient? Any chance that's finding its way back into the master/trunk, much less NuGet package? Thank ye!

New Post: No such File or Directory

New Post: Windows RT and signing

$
0
0
Unfortunately the library does not Support WinRT for now... I heard of guys who already ported it to WinRT but as you need to do really much low Level work with e.g. the new StreamSocket, that won't go public that soon i guess...

edit: stumbled over this via Google - didn't recognize the date

New Post: SFTP: Uploading Files to the FTP Server has Inconsistent Behavior

$
0
0
Im trying to upload file from my local to unix platform using sftp...any suggestions?? is this powershell script ????

New Post: Problem with Library ssh.net

$
0
0
hi every body

I'm using this library to connect to the Linux commands I run and run but
Some commands have problems

For example, I have a problem running these commands:

top and top -n 1

error:TERM environment variable not set.

 private void button2_Click(object sender, EventArgs e)
        {
            Renci.SshNet.SshClient sshClient = new Renci.SshNet.SshClient("192.168.150.128", "reza", "1");
            sshClient.Connect();
            var command = sshClient.RunCommand("top");
 
            var line = command.Result.Split('\n');
            List<ServerStatusCpu> serverstatus = new List<ServerStatusCpu>();
            for (int i = 3; i < line.Length - 1; i++)
            {
                var li = line[i];
                var words = li.Split(' ');
                List<string> fillterwords = new List<string>();
 
                foreach (var w in words)
                {
                    if (w != "")
                    {
                        fillterwords.Add(w);
                    }
                }
 
                ServerStatusCpu serverStatus = new ServerStatusCpu();
                serverStatus.Time = fillterwords[0];
                serverStatus.TimeType = fillterwords[1];
                serverStatus.Name = fillterwords[2];
                serverStatus.UserCpuTime = float.Parse(fillterwords[3].Replace("%", ""));
                serverStatus.UserNiceCpuTime = float.Parse(fillterwords[4].Replace("%", ""));
                serverStatus.SystemCpuTime = float.Parse(fillterwords[5].Replace("%", ""));
                serverStatus.IoWaitCpuTime = float.Parse(fillterwords[6].Replace("%", ""));
                serverStatus.IrqCpuTime = float.Parse(fillterwords[7].Replace("%", ""));
                serverStatus.SoftwareIrqCpuTime = float.Parse(fillterwords[8].Replace("%", ""));
                serverStatus.StealCpuTime = float.Parse(fillterwords[9].Replace("%", ""));
                serverStatus.GuestCpuTime = float.Parse(fillterwords[10].Replace("%", ""));
                serverStatus.IdleCpuTime = float.Parse(fillterwords[11].Replace("%", ""));
 
                serverstatus.Add(serverStatus);
            }
 
            dataGridView1.DataSource = serverstatus;
        }

class ServerStatusCpu

public class ServerStatusCpu
{
    public string Time { get; set; }

    public string TimeType { get; set; }

    public string Name { get; set; }

    public float UserCpuTime { get; set; }

    public float SystemCpuTime { get; set; }

    public float UserNiceCpuTime { get; set; }

    public float IdleCpuTime { get; set; }

    public float IoWaitCpuTime { get; set; }

    public float IrqCpuTime { get; set; }

    public float SoftwareIrqCpuTime { get; set; }

    public float StealCpuTime { get; set; }

    public float GuestCpuTime { get; set; }
}

New Post: SftpClient.Exists and SftpClient.DownloadFile CREATE a file on server if file does not exist

$
0
0
Did you happen to resolve this? I'm having the same problem with the exists method. It always returns true, and changing directory into an invalid path doesn't throw an exception either.

I'm also using sysax multi server.

Created Issue: Wrong PKCS7 padding in DES algorithm [1580]

$
0
0
public class PKCS7Padding : CipherPadding
{
/// <summary>
/// Transforms the specified input.
/// </summary>
/// <param name="blockSize">Size of the block.</param>
/// <param name="input">The input.</param>
/// <returns>
/// Padded data array.
/// </returns>
public override byte[] Pad(int blockSize, byte[] input)
{
var numOfPaddedBytes = blockSize - (input.Length % blockSize);

var output = new byte[input.Length + numOfPaddedBytes];
Buffer.BlockCopy(input, 0, output, 0, input.Length);
for (int i = 0; i < numOfPaddedBytes; i++)
{
//Wrong
//output[input.Length + i] = output[input.Length - 1];

//Should be like this
output[input.Length + i] = (byte)numOfPaddedBytes;
}

return output;
}
}

Created Issue: Unhandled exception during SftpClient Dispose [1581]

$
0
0
We are facing an unhandled exception during Dispose of the SftpClient.

2013-05-13 12:54:22,711 [2] FATAL - AppDomain.UnhandledException
Renci.SshNet.Common.SshConnectionException: Client not connected.
at Renci.SshNet.Session.SendMessage(Message message)
at Renci.SshNet.Channels.Channel.Close(Boolean wait)
at Renci.SshNet.Channels.ChannelSession.Close(Boolean wait)
at Renci.SshNet.Channels.Channel.Dispose(Boolean disposing)
at Renci.SshNet.Sftp.SubsystemSession.Dispose(Boolean disposing)
at Renci.SshNet.Sftp.SftpSession.Dispose(Boolean disposing)
at Renci.SshNet.SftpClient.Dispose(Boolean disposing)
at Renci.SshNet.BaseClient.Finalize()

This happens when the connection to the Ssh server is lost and affects our ability to gracefully handle situations when servers/connectivity goes down. O

The solution I suggest to swallow any exceptions coming from SftpClient.Dispose() as follows. Not pretty but as a general rule, Dispose shouldnt be throwing exceptions, unless such exceptions are symtomatic of a more serious problem.

Cheers

protected override void Dispose(bool disposing)
{
try
{
if (this._sftpSession != null)
{
this._sftpSession.Dispose();
this._sftpSession = null;
}

if (this._disposeConnectionInfo)
((IDisposable)this.ConnectionInfo).Dispose();

base.Dispose(disposing);
}
catch
{
// swallow it
}
}

New Post: SftpClient.Exists and SftpClient.DownloadFile CREATE a file on server if file does not exist

$
0
0
We just don't call Exists(). Get() or DownloadFile() seem to work as expected.
Viewing all 2955 articles
Browse latest View live


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