mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-05 22:44:55 +00:00
ssh: try other OpenSSH key types besides rsa
This commit is contained in:
@@ -5,7 +5,7 @@ import slugify from 'slugify'
|
||||
import * as yaml from 'js-yaml'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { PartialProfile } from 'tabby-core'
|
||||
import { SSHProfileImporter, PortForwardType, SSHProfile, SSHProfileOptions } from 'tabby-ssh'
|
||||
import { SSHProfileImporter, PortForwardType, SSHProfile, SSHProfileOptions, AutoPrivateKeyLocator } from 'tabby-ssh'
|
||||
|
||||
import { ElectronService } from './services/electron.service'
|
||||
|
||||
@@ -163,3 +163,25 @@ export class StaticFileImporter extends SSHProfileImporter {
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class PrivateKeyLocator extends AutoPrivateKeyLocator {
|
||||
async getKeys (): Promise<[string, Buffer][]> {
|
||||
const results: [string, Buffer][] = []
|
||||
const keysPath = path.join(process.env.HOME!, '.ssh')
|
||||
if (!fsSync.existsSync(keysPath)) {
|
||||
return results
|
||||
}
|
||||
for (const file of await fs.readdir(keysPath)) {
|
||||
if (/^id_[\w\d]+$/.test(file)) {
|
||||
const privateKeyContents = await fs.readFile(
|
||||
path.join(keysPath, file),
|
||||
{ encoding: null }
|
||||
)
|
||||
results.push([file, privateKeyContents])
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user