Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: issue with provided public key

Please post the actual error message.
DirtyHowi

issue with provided public key

I am trying to interface with a partner FTP site using SFTP, I've gotten the winscp package for .net.

code looks like

        protected void UploadViaWINSCP()

        {
            var sessionOptions = new SessionOptions
            {
                Protocol = Protocol.Sftp,
                HostName = ConfigurationManager.AppSettings["Host"],
                UserName = ConfigurationManager.AppSettings["username"],
                Password = ConfigurationManager.AppSettings["password"],
                SshHostKeyFingerprint = "ssh-rsa 1024 xx:xx:xx:xx etc",
                PortNumber = 22
            };
            var localfilename = @"~/DataStore/" + ViewState["FileName"];
            var remotefilename = Path.GetFileName(localfilename);
            using (var session = new Session())
            {
                session.DisableVersionCheck = true;
                session.Open(sessionOptions);  //gets here and crashes
                TransferOptions transfer = new TransferOptions();
                transfer.TransferMode = TransferMode.Binary;
                TransferOperationResult transferrResult;
                transferrResult = session.PutFiles(localfilename, remotefilename, false, transfer);
                transferrResult.Check();
            }
        }


see comment line above...it gets to the session.open(sessionoptions) and kicks back with server said public key, which i have in a .pub file (both server and other). How do i use the public key file provided by the trading partner to upload a file to them, basically on demand, this is part of a larger asp.net project, 4.5 framework.