mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-19 18:07:58 +00:00
ssh: try other OpenSSH key types besides rsa
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { NgModule } from '@angular/core'
|
||||
import { PlatformService, LogService, UpdaterService, DockingService, HostAppService, ThemesService, Platform, AppService, ConfigService, WIN_BUILD_FLUENT_BG_SUPPORTED, isWindowsBuild, HostWindowService, HotkeyProvider, ConfigProvider, FileProvider } from 'tabby-core'
|
||||
import { TerminalColorSchemeProvider } from 'tabby-terminal'
|
||||
import { SFTPContextMenuItemProvider, SSHProfileImporter } from 'tabby-ssh'
|
||||
import { SFTPContextMenuItemProvider, SSHProfileImporter, AutoPrivateKeyLocator } from 'tabby-ssh'
|
||||
import { auditTime } from 'rxjs'
|
||||
|
||||
import { HyperColorSchemes } from './colorSchemes'
|
||||
@@ -17,7 +17,7 @@ import { ElectronService } from './services/electron.service'
|
||||
import { ElectronHotkeyProvider } from './hotkeys'
|
||||
import { ElectronConfigProvider } from './config'
|
||||
import { EditSFTPContextMenu } from './sftpContextMenu'
|
||||
import { OpenSSHImporter, StaticFileImporter } from './sshImporters'
|
||||
import { OpenSSHImporter, PrivateKeyLocator, StaticFileImporter } from './sshImporters'
|
||||
|
||||
@NgModule({
|
||||
providers: [
|
||||
@@ -34,6 +34,7 @@ import { OpenSSHImporter, StaticFileImporter } from './sshImporters'
|
||||
{ provide: SFTPContextMenuItemProvider, useClass: EditSFTPContextMenu, multi: true },
|
||||
{ provide: SSHProfileImporter, useExisting: OpenSSHImporter, multi: true },
|
||||
{ provide: SSHProfileImporter, useExisting: StaticFileImporter, multi: true },
|
||||
{ provide: AutoPrivateKeyLocator, useExisting: PrivateKeyLocator, multi: true },
|
||||
],
|
||||
})
|
||||
export default class ElectronModule {
|
||||
|
@@ -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