1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-12-24 11:02:47 +03:00
This commit is contained in:
Eugene Pankov 2021-06-20 17:14:31 +02:00
parent 552991271f
commit 2af1e6e6ac
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
4 changed files with 28 additions and 12 deletions

View File

@ -6,6 +6,7 @@ import { ToastrModule } from 'ngx-toastr'
import TerminusCorePlugin, { HostAppService, ToolbarButtonProvider, TabRecoveryProvider, ConfigProvider, HotkeysService, HotkeyProvider, TabContextMenuItemProvider, CLIHandler, ConfigService } from 'terminus-core'
import TerminusTerminalModule from 'terminus-terminal'
import TerminusElectronPlugin from 'terminus-electron'
import { SettingsTabProvider } from 'terminus-settings'
import { TerminalTabComponent } from './components/terminalTab.component'
@ -47,6 +48,7 @@ import { AutoOpenTabCLIHandler, OpenPathCLIHandler, TerminalCLIHandler } from '.
NgbModule,
ToastrModule,
TerminusCorePlugin,
TerminusElectronPlugin,
TerminusTerminalModule,
],
providers: [

View File

@ -19,6 +19,7 @@
width: 190px;
flex: none;
overflow-y: auto;
flex-wrap: nowrap;
}
> .tab-content {

View File

@ -320,16 +320,23 @@ export class SSHSession extends BaseSession {
this.remainingAuthMethods = [{ type: 'none' }]
if (!this.connection.auth || this.connection.auth === 'publicKey') {
for (const pk of this.connection.privateKeys ?? []) {
try {
this.remainingAuthMethods.push({
type: 'publickey',
name: pk,
contents: await this.fileProviders.retrieveFile(pk),
})
} catch (error) {
this.emitServiceMessage(colors.bgYellow.yellow.black(' ! ') + ` Could not load private key ${pk}: ${error}`)
if (this.connection.privateKeys?.length) {
for (const pk of this.connection.privateKeys) {
try {
this.remainingAuthMethods.push({
type: 'publickey',
name: pk,
contents: await this.fileProviders.retrieveFile(pk),
})
} catch (error) {
this.emitServiceMessage(colors.bgYellow.yellow.black(' ! ') + ` Could not load private key ${pk}: ${error}`)
}
}
} else {
this.remainingAuthMethods.push({
type: 'publickey',
name: 'auto',
})
}
}
if (!this.connection.auth || this.connection.auth === 'agent') {
@ -717,7 +724,7 @@ export class SSHSession extends BaseSession {
const userKeyPath = path.join(process.env.HOME!, '.ssh', 'id_rsa')
if (await fs.exists(userKeyPath)) {
this.emitServiceMessage('Using user\'s default private key')
privateKeyContents = fs.readFile(userKeyPath, { encoding: null })
privateKeyContents = await fs.readFile(userKeyPath, { encoding: null })
}
}
@ -740,11 +747,17 @@ export class SSHSession extends BaseSession {
async parsePrivateKey (privateKey: string): Promise<any> {
const keyHash = crypto.createHash('sha512').update(privateKey).digest('hex')
let passphrase: string|null = await this.passwordStorage.loadPrivateKeyPassword(keyHash)
let triedSavedPassphrase = false
let passphrase: string|null = null
while (true) {
try {
return sshpk.parsePrivateKey(privateKey, 'auto', { passphrase })
} catch (e) {
if (!triedSavedPassphrase) {
passphrase = await this.passwordStorage.loadPrivateKeyPassword(keyHash)
triedSavedPassphrase = true
continue
}
if (e instanceof sshpk.KeyEncryptedError || e instanceof sshpk.KeyParseError) {
await this.passwordStorage.deletePrivateKeyPassword(keyHash)

View File

@ -64,6 +64,7 @@ export class EditConnectionModalComponent {
)
async ngOnInit () {
this.connection.algorithms = this.connection.algorithms ?? {}
for (const k of Object.values(SSHAlgorithmType)) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!this.connection.algorithms[k]) {
@ -76,7 +77,6 @@ export class EditConnectionModalComponent {
}
}
this.connection.algorithms = this.connection.algorithms ?? {}
this.connection.scripts = this.connection.scripts ?? []
this.connection.auth = this.connection.auth ?? null
this.connection.privateKeys ??= []