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

- Use unencrypted private key (without passphrase) for automation
- Or in scripting using the -passphrase switch of the open command
- in .NET assembly, use the PrivateKeyPassphrase property.
Adam_231

Nice one, I'll give that a go!

Thanks :)
savoym

Hi Adam,

Sorry for the late response. Had a project issue.

Here is my $sessionOptions value:

$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = "XXXsftp1.xxx.xxx.com"
UserName = "username"
SshHostKeyFingerprint = "ssh-rsa 2048 ..."
SshPrivateKeyPath = "C:\Dir\SDir1\SDir2\SDir3\test.ppk"
PrivateKeyPassphrase = "0000MYPASSPHRASE"
}

$session = New-Object WinSCP.Session

try {

#Connect
$session.Open($sessionOptions)...

Hope this works for you.
Adam_231

savoym wrote:

I've put it in my powershell script


You've been able to automate the insertion of the passphrase from a Powershell script?

If so, I'd be keen to see how you did that!

Adam
savoym

Thanks for the response.

I've put it in my powershell script but just wanted to see if I could do the same in the GUI. This is a vendor that we're logging into and they require it.
Adam_231

savoym wrote:

Adam, did you find an answer to your question.

I have the same question. Is there a way to automate this in the GUI login dialog?

A response would be appreciated. Thanks.


I'm afraid, as best I could find out, this isn't possible. The passphrase seems to be an interactive response only.

In our case we resolved it by recreating the cert without the passphrase. Would have been nice to be able to do it, but hey :/

Adam
savoym

Adam, did you find an answer to your question.

I have the same question. Is there a way to automate this in the GUI login dialog?

A response would be appreciated. Thanks.
Adam_231

Passphrase for RSA key prompt

Hi,

Apologies if I'm asking something stupid here, but its the first time I've tried automating an sftp connection....

I have a site setup within the WinSCP gui which works well. When I connect it asks me for my Passphrase for the rsa key, which when I enter it then connects and all is well.

I've used the script generator option (with all options selected) to have it give me the connection details I need. However, when I run the script manually from the command line it then produces the same prompt for password as per the below;

Authenticating with public key "rsa-key-20161216".
Passphrase for key 'rsa-key-20161216':

Of course, if I manually add the key on the command line it will then connect. However, I'm hoping to automate the connection completely so I can script certain uploads/downloads as a scheduled task from Windows.

Could someone point me in the right direction?

Thanks in advance

Adam