使用 Putty 命令行 PSFTP.exe 输入私钥密码

Eri*_*ric 8 putty private-key

我正在使用 psftp.exe 自动下载文件,但需要使用私钥连接,如下所述。我能够连接,但是,私钥需要密码。

此过程有效,但我必须从键盘输入密码,这会破坏从命令行运行的过程。我想知道是否有人可以告诉我如何在命令行中发送密码。

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.  
Run Code Online (Sandbox Code Playgroud)

如上所述,谁能告诉我如何在命令行中发送私钥密码?

Zor*_*che 11

为什么不直接从密钥中删除密码?如果您只是要将密码保存在配置文件或脚本中的某处,那么在您的密钥上设置密码没有任何价值。

只需使用 puttygen 加载您的 ppk 文件,删除密码并保存。

您当然可以制作您的 ppk 的副本并仅从该副本中删除短语,然后使用文件系统 ACL 保护该副本以将风险降至最低。


use*_*517 7

您可以在登录时将密钥加载到选美中,只需提供一次密码即可。只要 pageant 正在运行,那么所有 psftp/PuTTy/plink 连接都将使用存储在其中的密钥。