Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
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
add comment

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.

share|improve this answer
    
This answer does work but for my situation the other answer is a better solution. Thank you. –  Eric May 12 '11 at 17:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.