8

I'm using psftp.exe to automate a file download but need to connect with a private key as explained below. I am able to connect, however, the private key requires a Passphrase.

This procedure works but I have to enter the Passphrase from the keyboard, which defeats the process of running from command line. I would like to know if anyone can tell me how to send the Passphrase in the command line.

Using Putty's PSFTP.exe With A Private Key

Command Line:

    c:\putty\psftp.exe username@ftpsite.com -i putty_id_rsa_1024.ppk -b c:\putty\myscript.scr

Command Line Notes:  Replace username with your login name and modify the "putty_id_rsa_1024.ppk" key name to match your key. In order to use a key, you will need to use puttygen.exe to generate, import, and or export your keys. PuTTY requires a putty key file to make a private key connection. 

myscript.scr file contents:

cd /
put File1.txt

put File2.txt

put File3.txt

close

Script Notes: Each command is a standard Unix navigation command.  

As mentioned above, can anyone tell me how to send the private key Passphrase in the command line?

Zoredache
  • 130,897
  • 41
  • 276
  • 420
Eric
  • 83
  • 1
  • 1
  • 3

2 Answers2

12

Why not just remove the passphrase from the key? There is no value in having a passphrase on your key if you are just going to save the password somewhere in a config file or script.

Just load up your ppk file with puttygen, remove the password and save.

You can certainly make a copy of your ppk just and strip the phrase just from that copy, and then protect that copy with filesystem ACLs to minimize the risk.

Zoredache
  • 130,897
  • 41
  • 276
  • 420
  • Perfect! I was not aware I could remove the passphrase without having to do another key exchange with the transfer partner. Thanks for your help! – Eric May 12 '11 at 17:21
7

You can load the key into pageant when you log in and provide the passphrase just once. As long as pageant is running then all psftp/PuTTy/plink connections will use the key stored in it.

user9517
  • 115,471
  • 20
  • 215
  • 297
  • This answer does work but for my situation the other answer is a better solution. Thank you. – Eric May 12 '11 at 17:22