File Transfer using SSH.Net to SFTP Server

Aug 24, 2012 at 12:29 PM

Hi ,

I am new to SSH.Net. I have got a public Key file id_rsa.pub with me. I have no idea where to start and how to use this public key file. Could you please help me on this?

I am using .Net 3.5 and i am creating couple of delimited text files and i want these text files needed to be transferred to a SFTP Server.

Please help on this.

 

 

Aug 24, 2012 at 8:38 PM
Edited Aug 24, 2012 at 8:38 PM

Hi there

Did you already look at the samples? If you did  and you're still stuck, I can get you going in the right direction.

Aug 29, 2012 at 10:57 AM

Hi Michael,

 

I looked at the samples. And I have once question. I have only a public Key file named as id_rsa.Pub. I can see a function to connect the SFTP using SFTPClient(string host, string username, params Renci.SshNet.PrivateKeyFile[] Keyfiles)

 

Please let me know steps for creating the private key file?

 

 

 

 

Aug 29, 2012 at 1:02 PM
I don't think you can create a private key file from a public key file, that would be bad security! It sounds to me like you need to generate a new key-pair. When you do this, you will end up with a new public and private key file.

You can then supply the public key file to the location that you are trying to ssh to.

Hope this helps
Michael



On Wed, Aug 29, 2012 at 6:57 AM, ravisulur <notifications@codeplex.com> wrote:

From: ravisulur

Hi Michael,

I looked at the samples. And I have once question. I have only a public Key file named as id_rsa.Pub. I can see a function to connect the SFTP using SFTPClient(string host, string username, params Renci.SshNet.PrivateKeyFile[] Keyfiles)

Please let me know steps for creating the private key file?

 

Read the full discussion online.

To add a post to this discussion, reply to this email (sshnet@discussions.codeplex.com)

To start a new discussion for this project, email sshnet@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Sep 4, 2012 at 12:15 PM

Hi Michel

Is there any way that we can connect the SFTPClient without username? Is it possible to do it only with these key pairs? How to find out the Private key is correct one?

I am pasting the private key for your reference.

-----BEGIN RSA PRIVATE KEY-----
MIIEoQIBAAKCAQEA2ChGgh43/a6ppl/4GKkBiqqUkhCyu7LX1hjefXPD6ZVTKDY2
FWNAvi5TnQBk9mu5nVJyZG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1RpacOi1
FnDYdTrWh3+hqmtLPSDLxZswcUfFR0SRS7+BPrJHoCDa6hPKJoZLgBemhVYCQsKD
UckPX/lvp54QhQgIB5bbAoGAGZl1OyBYUNKHxD9XXlfyC0bI8GL6Sk0ksrMY1UDO
XriR7/J0pkdYO1DrtC3KV5ci+UG8RHcDrftoeJ2a1x8haXwm+ADx+pgeXHWVBiAi
ysyDYJCWcB+e6jKjDHQHx5hEwq6LYWY0pHLLEf5aomYKYeEdR+Tw2VbOI3kldLTZ
ieMCgYAjN7XT+4nUVUqXA5LaW4GHV4wlqz/b41PvLFR4Ns8hiqPkACod71mSexI8
/Nze9mvVmc5gOJv0bMG2KVeXs4FBUvEW/7Gvahzz1iivIa601lDX122feUldlLF8
Ye3uixs3/lIenVJ0fDL3j8X9wwtkVN/YRNoiMZjIOWXqncsGYw==
-----END RSA PRIVATE KEY-----

Sep 5, 2012 at 4:24 AM

  HI Michel,

 

I am able to connect the SFTP server using SFTP.Connect() and able to change directory. But I am unable to upload the file since it is throwing the exception as "Failure" I have attached the stacktrace for your reference.

   at Renci.SshNet.Sftp.SubsystemSession.WaitHandle(WaitHandle waitHandle, TimeSpan operationTimeout)
   at Renci.SshNet.Sftp.SftpSession.RequestOpen(String path, Flags flags, Boolean nullOnError)
   at Renci.SshNet.SftpClient.InternalUploadFile(Stream input, String path, SftpUploadAsyncResult asynchResult, Flags flags)
   at Renci.SshNet.SftpClient.UploadFile(Stream input, String path, Boolean canOverride)
   at Renci.SshNet.SftpClient.UploadFile(Stream input, String path)

Please help me out to solve this issue?

 

Sep 5, 2012 at 9:31 AM

sorry for the inconvenience. One of the discussion has solved my problem. the actual problem is i have not specified the file name while uploading. I have given the path and trying to upload.

 

thanks a lot for your help team!