Topic "Passphrase for RSA key prompt"

Author Message
Adam_231
[View user's profile]

Joined: 2017-01-18
Posts: 4
Location: UK
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
Advertisements
savoym
[View user's profile]

Joined: 2016-09-27
Posts: 5
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
[View user's profile]

Joined: 2017-01-18
Posts: 4
Location: UK
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
[View user's profile]

Joined: 2016-09-27
Posts: 5
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
[View user's profile]

Joined: 2017-01-18
Posts: 4
Location: UK
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
[View user's profile]

Joined: 2016-09-27
Posts: 5
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
[View user's profile]

Joined: 2017-01-18
Posts: 4
Location: UK
Nice one, I'll give that a go!

Thanks Smile
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26108
Location: Prague, Czechia
- 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.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License