I am trying to make a simple PowerShell function for a Linux-style ssh command. For instance:
ssh username@url
I use plink for this and this is the function I wrote:
function ssh {
param($usernameAndServer)
$myArray = $usernameAndServer.Split("@")
$myArray[0] | C:\plink.exe -ssh $myArray[1]
}
When entered correctly by the user, $ myArray [0] is the name of the user, and $ myArray [1] is the URL. Thus, it connects to the URL, and when you are prompted for a username, the username will be broadcast using the pipeline. Everything works fine, except that the pipeline continues to feed the username ($ myArray [0]), and it is entered as a password again and again. Example:
PS C:\Users\Mike> ssh xxxxx@yyyyy
login as: xxxxx@yyyyy password:
Access denied
xxxxx@yyyyy password:
Access denied
xxxxx@yyyyy password:
Access denied
xxxxx@yyyyy password:
Access denied
xxxxx@yyyy password:
Access denied
xxxxx@yyyyy password:
FATAL ERROR: Server sent disconnect message
type 2 (protocol error):
"Too many authentication failures for xxxxx"
If the username has been replaced by xxxxx and the URL has been replaced by yyyyy.
, , script ($ myArray [0]) , .
? .