シンプルなPowerShell関数を使って、Linuxスタイルのsshコマンドを作成しようとしています。以下のような:Powershellのパイプライン文字列
私はこれを行うにはPLINK使用していて、これは私が書いた関数である:[0]であるユーザー、$ MyArrayということで正しく入力されている場合
function ssh {
param($usernameAndServer)
$myArray = $usernameAndServer.Split("@")
$myArray[0] | C:\plink.exe -ssh $myArray[1]
}
ユーザー名と$ myArray [1]はURLです。したがって、URLに接続し、ユーザー名の入力が求められたら、ユーザー名はパイプラインを使用してストリーミングされます。パイプラインがユーザー名($ myArray [0])を供給し続けることを除いて、すべてが完璧に動作し、パスワードとして何度も入力されます。例:
PS C:\Users\Mike> ssh [email protected]
login as: [email protected]'s password:
Access denied
[email protected]'s password:
Access denied
[email protected]'s password:
Access denied
[email protected]'s password:
Access denied
[email protected]'s password:
Access denied
[email protected]'s password:
FATAL ERROR: Server sent disconnect message
type 2 (protocol error):
"Too many authentication failures for xxxxx"
ユーザー名がxxxxxで置き換えられ、URLがyyyyyに置き換えられています。
基本的には、一度入力した後に、ユーザー名($ myArray [0])でスクリプトを停止する方法を調べる必要があります。
アイデア?私は解決策のためにインターネットのいたるところを見てきましたが、何も見つけられませんでした。
Dohのは、完璧に働いた、ありがとう! –