Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions tabby-ssh/src/session/ssh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class SSHSession {
if (!this.profile.options.auth || this.profile.options.auth === 'agent') {
const spec = await this.getAgentConnectionSpec()
if (!spec) {
this.emitServiceMessage(colors.bgYellow.yellow.black(' ! ') + ` Agent auth selected, but no running Agent process is found`)
// getAgentConnectionSpec() already emitted a detailed reason.
} else {
// If user configured specific private keys, try to load their corresponding
// .pub files and use them first for agent-identity authentication
Expand Down Expand Up @@ -329,9 +329,33 @@ export class SSHSession {
}
}
} else {
const configuredPath = (this.config.store.ssh.agentPath ?? '').trim()
const envPath = (process.env.SSH_AUTH_SOCK ?? '').trim()
const agentSocketPath = configuredPath || envPath

if (!agentSocketPath) {
this.emitServiceMessage(colors.bgYellow.yellow.black(' ! ') + ' Agent auth selected, but SSH_AUTH_SOCK is not set')
return null
}

// Skip filesystem checks for abstract namespace sockets.
if (!agentSocketPath.startsWith('@')) {
try {
const stat = await fs.stat(agentSocketPath)
if (!stat.isSocket()) {
this.emitServiceMessage(colors.bgYellow.yellow.black(' ! ') + ` Agent socket path is not a Unix socket: ${agentSocketPath}`)
return null
}
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
this.emitServiceMessage(colors.bgYellow.yellow.black(' ! ') + ` Could not access agent socket ${agentSocketPath}: ${e}`)
return null
}
}

return {
kind: 'unix-socket',
path: process.env.SSH_AUTH_SOCK!,
path: agentSocketPath,
}
}
return null
Expand Down
Loading