1

ssh を含む bash から多くの関数を呼び出す tcl スクリプトがあります。私が苦労している部分は次のようになります。

proc connect {where} {
    set bash c:/cygwin/bin/bash
    catch {exec $bash -c "ssh $where"} result
    puts $result
}
connect user@localhost

認証失敗メッセージが表示されます。

Pseudo-terminal will not be allocated because stdin is not a terminal.
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password,keyboard-interactive).

ユーザーにパスワードを要求する方法がわかりません (コンソールを表示するか、tk ウィンドウを表示するかは問題ではありません)。

私が bash を ssh に使用している理由は、最終的にスクリプトを使用して github に接続したいからです (パスキーを要求する必要があります)。

4

2 に答える 2

2

これを試して:

puts -nonewline "enter your passphrase: "
flush stdout
gets stdin passphrase
exec $bash -c "ssh $where" << $passphrase

への<<引数execは、指定された値を標準入力のコマンドに渡します

それでもうまくいかない場合は、Expect を試すか、パスフレーズのないキーを使用する必要があります。

于 2010-06-10T17:42:26.920 に答える
0

One important alternative (which I advise) is to set up a local key-handling agent (e.g., ssh-agent or pageant) to hold the decrypted key so that your code doesn't need to handle passwords at all. I find that's a much simpler method overall because it stops a lot of code from having to understand anything about passwords (which are harder to handle correctly than you might think…)

于 2010-06-15T13:06:22.260 に答える