Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- // Setup session options
- SessionOptions sessionOptions = new SessionOptions
- {
- Protocol = Protocol.Scp,
- HostName = "192.168.0.2",
- UserName = "opie",
- Password = "opie",
- //SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
- };
- using (Session session = new Session())
- {
- // Connect
- session.DisableVersionCheck = true;
- sessionOptions.GiveUpSecurityAndAcceptAnySshHostKey = true;
- session.Open(sessionOptions);
- // Upload files
- TransferOptions transferOptions = new TransferOptions();
- transferOptions.TransferMode = TransferMode.Binary;
- TransferOperationResult transferResult;
- transferResult = session.PutFiles(@"H:toupload*", "/home/opie/test.txt", false, transferOptions);
- // Throw on any error
- transferResult.Check();
- // Print results
- foreach (TransferEventArgs transfer in transferResult.Transfers)
- {
- //Debug.Log("Upload of {0} succeeded", transfer.FileName);
- Debug.Log("Upload of " + transfer.FileName + " succeeded");
- }
- }
- Debug.Log("winSCP connection succeeded");
- return;
- }
- catch (Exception e)
- {
- Debug.Log("Error: {0}" + e);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement