@@ -35,6 +35,7 @@ interface Options {
3535 agentSocket ?: string ,
3636 skipAutoPrivateKey ?: boolean
3737 noReadline ?: boolean
38+ readyTimeout ?: number
3839}
3940
4041interface ForwardingOptions {
@@ -59,15 +60,15 @@ class SSHConnection {
5960 this . options . endPort = 22
6061 }
6162 if ( ! options . privateKey && ! options . agentForward && ! options . skipAutoPrivateKey ) {
62- const defaultFilePath = path . join ( os . homedir ( ) , '.ssh' , 'id_rsa' )
63+ const defaultFilePath = path . join ( os . homedir ( ) , '.ssh' , 'id_rsa' )
6364 if ( fs . existsSync ( defaultFilePath ) ) {
6465 this . options . privateKey = fs . readFileSync ( defaultFilePath )
6566 }
6667 }
6768 }
6869
6970 public async shutdown ( ) {
70- this . debug ( " Shutdown connections" )
71+ this . debug ( ' Shutdown connections' )
7172 for ( const connection of this . connections ) {
7273 connection . removeAllListeners ( )
7374 connection . end ( )
@@ -82,7 +83,7 @@ class SSHConnection {
8283
8384 public async tty ( ) {
8485 const connection = await this . establish ( )
85- this . debug ( " Opening tty" )
86+ this . debug ( ' Opening tty' )
8687 await this . shell ( connection )
8788 }
8889
@@ -155,6 +156,9 @@ class SSHConnection {
155156 password : this . options . password ,
156157 privateKey : this . options . privateKey
157158 }
159+ if ( this . options . readyTimeout ) {
160+ options [ 'readyTimeout' ] = this . options . readyTimeout
161+ }
158162 if ( this . options . agentForward ) {
159163 options [ 'agentForward' ] = true
160164
@@ -181,7 +185,7 @@ class SSHConnection {
181185 // in fact they always contain a `encryption` header, so we can't do a simple check
182186 options [ 'passphrase' ] = this . options . passphrase
183187 const looksEncrypted : boolean = this . options . privateKey ? this . options . privateKey . toString ( ) . toLowerCase ( ) . includes ( 'encrypted' ) : false
184- if ( looksEncrypted && ! options [ 'passphrase' ] && ! this . options . noReadline ) {
188+ if ( looksEncrypted && ! options [ 'passphrase' ] && ! this . options . noReadline ) {
185189 options [ 'passphrase' ] = await this . getPassphrase ( )
186190 }
187191 connection . on ( 'ready' , ( ) => {
@@ -198,7 +202,6 @@ class SSHConnection {
198202 reject ( error )
199203 }
200204
201-
202205 } )
203206 }
204207
0 commit comments