File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -39,10 +39,21 @@ export class SSHServer {
3939
4040 constructor ( ) {
4141 const sshConfig = getSSHConfig ( ) ;
42+ const privateKeys : Buffer [ ] = [ ] ;
43+
44+ try {
45+ privateKeys . push ( fs . readFileSync ( sshConfig . hostKey . privateKeyPath ) ) ;
46+ } catch ( error ) {
47+ console . error (
48+ `Error reading private key at ${ sshConfig . hostKey . privateKeyPath } . Check your SSH host key configuration or disbale SSH.` ,
49+ ) ;
50+ process . exit ( 1 ) ;
51+ }
52+
4253 // TODO: Server config could go to config file
4354 this . server = new ssh2 . Server (
4455 {
45- hostKeys : [ fs . readFileSync ( sshConfig . hostKey . privateKeyPath ) ] ,
56+ hostKeys : privateKeys ,
4657 authMethods : [ 'publickey' , 'password' ] as any ,
4758 keepaliveInterval : 20000 , // 20 seconds is recommended for SSH connections
4859 keepaliveCountMax : 5 , // Recommended for SSH connections is 3-5 attempts
You can’t perform that action at this time.
0 commit comments