allow forcing ssh agent type

This commit is contained in:
Eugene Pankov 2021-06-27 10:46:59 +02:00
parent 5a894ebfd3
commit fce8565835
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
3 changed files with 40 additions and 7 deletions

View File

@ -10,7 +10,7 @@ import stripAnsi from 'strip-ansi'
import socksv5 from 'socksv5'
import { Injector, NgZone } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { FileProvidersService, HostAppService, Logger, NotificationsService, Platform, PlatformService, wrapPromise } from 'terminus-core'
import { ConfigService, FileProvidersService, HostAppService, Logger, NotificationsService, Platform, PlatformService, wrapPromise } from 'terminus-core'
import { BaseSession } from 'terminus-terminal'
import { Server, Socket, createServer, createConnection } from 'net'
import { Client, ClientChannel, SFTPWrapper } from 'ssh2'
@ -281,6 +281,7 @@ export class SSHSession extends BaseSession {
private notifications: NotificationsService
private zone: NgZone
private fileProviders: FileProvidersService
private config: ConfigService
constructor (
injector: Injector,
@ -294,6 +295,7 @@ export class SSHSession extends BaseSession {
this.notifications = injector.get(NotificationsService)
this.zone = injector.get(NgZone)
this.fileProviders = injector.get(FileProvidersService)
this.config = injector.get(ConfigService)
this.scripts = connection.scripts ?? []
this.destroyed$.subscribe(() => {
@ -307,12 +309,18 @@ export class SSHSession extends BaseSession {
async init (): Promise<void> {
if (this.hostApp.platform === Platform.Windows) {
if (await fs.exists(WINDOWS_OPENSSH_AGENT_PIPE)) {
this.agentPath = WINDOWS_OPENSSH_AGENT_PIPE
} else {
if (await this.platform.isProcessRunning('pageant.exe')) {
this.agentPath = 'pageant'
if (this.config.store.ssh.agentType === 'auto') {
if (await fs.exists(WINDOWS_OPENSSH_AGENT_PIPE)) {
this.agentPath = WINDOWS_OPENSSH_AGENT_PIPE
} else {
if (await this.platform.isProcessRunning('pageant.exe')) {
this.agentPath = 'pageant'
}
}
} else if (this.config.store.ssh.agentType === 'pageant') {
this.agentPath = 'pageant'
} else {
this.agentPath = this.config.store.ssh.agentPath || WINDOWS_OPENSSH_AGENT_PIPE
}
} else {
this.agentPath = process.env.SSH_AUTH_SOCK!

View File

@ -64,10 +64,33 @@ h3.mt-5 Options
.form-line(*ngIf='hostApp.platform === Platform.Windows')
.header
.title WinSCP path
.descriptions When WinSCP is detected, you can launch an SCP session from the context menu.
.description When WinSCP is detected, you can launch an SCP session from the context menu.
input.form-control(
type='text',
placeholder='Auto-detect',
[(ngModel)]='config.store.ssh.winSCPPath',
(ngModelChange)='config.save()',
)
.form-line(*ngIf='hostApp.platform === Platform.Windows')
.header
.title Agent type
.description Forces a specific SSH agent connection type.
select.form-control(
[(ngModel)]='config.store.ssh.agentType',
(ngModelChange)='config.save()',
)
option(value='auto') Automatic
option(value='pageant') Pageant
option(value='pipe') Named pipe
.form-line(*ngIf='config.store.ssh.agentType === "pipe"')
.header
.title Agent pipe path
.description Sets the SSH agent's named pipe path.
input.form-control(
type='text',
placeholder='Default: \\\\.\\pipe\\openssh-ssh-agent',
[(ngModel)]='config.store.ssh.agentPath',
(ngModelChange)='config.save()',
)

View File

@ -8,6 +8,8 @@ export class SSHConfigProvider extends ConfigProvider {
recentConnections: [],
warnOnClose: false,
winSCPPath: null,
agentType: 'auto',
agentPath: null,
},
hotkeys: {
ssh: [