Problem with Passphrase option in Script

Advertisement

heiko80
Joined:
Posts:
4
Location:
DE

Problem with Passphrase option in Script

Hi,
I have created a script using Private Key Files. Also using the -passphrase option. But my Passphrase isn't working. I suggest it is a problem with special characters.

Passphrase: My,P%=!#"a$=k"-5,2"23'"phase
This is an example with same special characters as the original.

Is there any way I could automate my script without changing the Passphrase (not possible for me).

Script:
option batch on
 
option confirm off
 
open sftp://username@1.2.3.4:1234/ -hostkey="ssh-rsa 2048 xyzwvIj/Gsk48njdh6geGF6uXwqAtnfgMV7qUPy202w" -privatekey="D:\Pfad\priv.ppk" -passphrase="My,P%=!#"a$=k"-5,2"23'"phase"
lcd D:\Pfad\Import
cd home
cd data
get file.txt
close
exit
If I use the Script without -passphrase option and enter the Passphrase manually when asked for, it works.
Description: anonymized logfile

Reply with quote

Advertisement

user564758
Joined:
Posts:
23

-passphrase="My,P%=!#"a$=k"-5,2"23'"phase"
Most likely that you chose you use double quotes inside a double quoted string.

100% of the times it's better to not have password that contains certain characters, like single or double quotes or ending in an escape character.

Use a password with no quotes or escape them. See how that goes.

Reply with quote

heiko80
Joined:
Posts:
4
Location:
DE

In fact, that was my initial assumption...

I can't change the password on my own, it is really complex to do so. If it was this easy, I would do that already.

Tried also Encoding like in Password field, but it seems this is not possible in Passphrase field.

Reply with quote

heiko80

Hi,
I read about Pageant already, but as this is a customer environment, it is not so easy to install a new software.
So I would prefer a solution without additional software if possible. Maybe there is any way I could pass my Passphrase trough the -passphrase option.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,567
Location:
Prague, Czechia

Re: Problem with Passphrase option in Script

You have to double the double quotes:
-passphrase="My,P%=!#""a$=k""-5,2""23'""phase"
See https://winscp.net/eng/docs/scripting#quotes

Though in general, I do not see what is complicated about re-saving your private key with more sensible passphrase. Just load your key to PuTTYgen, change the passphrase and save it back.

Reply with quote

heiko80
Joined:
Posts:
4
Location:
DE

@martin
Many Many THANKS!!! It works now!
Searched hours trough the FAQ and Forum, but did not notice this hint.

I'm not allowed to change Keys. It is a customer managed enviroment with limited access for me.

Reply with quote

Advertisement

You can post new topics in this forum