@@ -100,7 +100,7 @@ static void Start(Options options)
100
100
else if ( options . Password )
101
101
{
102
102
Console . WriteLine ( "No SSH key file selected, using password auth instead." ) ;
103
- var pass = ReadLine . ReadPassword ( "Please enter password: " ) ;
103
+ var pass = ReadPassword ( "Please enter password: " ) ;
104
104
105
105
auths . AddRange ( new ( string , ConnectionInfo ) [ ]
106
106
{
@@ -122,12 +122,21 @@ static PrivateKeyConnectionInfo PrivateKeyConnectionInfo(Options options)
122
122
{
123
123
var pkFiles = options . Keys . Select ( k =>
124
124
options . Password
125
- ? new PrivateKeyFile ( k , ReadLine . ReadPassword ( $ "Enter passphrase for { k } : ") )
125
+ ? new PrivateKeyFile ( k , ReadPassword ( $ "Enter passphrase for { k } : ") )
126
126
: new PrivateKeyFile ( k ) ) ;
127
127
128
128
return new PrivateKeyConnectionInfo ( options . Host , options . Port , options . Username , pkFiles . ToArray ( ) ) ;
129
129
}
130
130
131
+ static string ReadPassword ( string prompt )
132
+ {
133
+ if ( ! Console . IsInputRedirected )
134
+ return ReadLine . ReadPassword ( prompt ) ;
135
+
136
+ Console . WriteLine ( prompt ) ;
137
+ return Console . ReadLine ( ) ;
138
+ }
139
+
131
140
static KeyboardInteractiveConnectionInfo KeyboardInteractiveConnectionInfo ( Options options , string pass )
132
141
{
133
142
var auth = new KeyboardInteractiveConnectionInfo ( options . Host , options . Port , options . Username ) ;
0 commit comments