Passphrase for RSA key prompt

Advertisement

Adam_231
Joined:
Posts:
4
Location:
UK

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

Reply with quote

Advertisement

savoym
Joined:
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.

Reply with quote

Adam_231
Joined:
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

Reply with quote

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.

Reply with quote

Adam_231
Joined:
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

Reply with quote

Advertisement

savoym
Joined:
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.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
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.

Reply with quote

Advertisement

You can post new topics in this forum