mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Add skip SSH host key verification and fix self-hosted server support (#121)
* Add SSH host key verification with automatic trust and SCP-style URL support * Fix TypeScript errors for SSH host key schema and test mocks
This commit is contained in:
1 parent
677ce748cd
commit
7341dce1ef
25 files changed
+203
-123
No files matched your search
@@ -98,10 +98,29 @@ export class SSHHostKeyHandler implements IPCHandler {
|
||||
}
|
||||
}
|
||||
|
||||
async autoAcceptHostKey(repoUrl: string): Promise<void> {
|
||||
const { host, port } = parseSSHHost(repoUrl)
|
||||
const hostPort = normalizeHostPort(host, port)
|
||||
|
||||
const trustedHost = this.getTrustedHost(hostPort)
|
||||
if (trustedHost) {
|
||||
logger.info(`Host ${hostPort} already trusted, skipping auto-accept`)
|
||||
return
|
||||
}
|
||||
|
||||
const publicKey = await this.fetchHostPublicKey(host, port)
|
||||
await this.addToKnownHosts(hostPort, publicKey)
|
||||
this.saveTrustedHost(hostPort, publicKey)
|
||||
logger.info(`Auto-accepted SSH host key for ${hostPort}`)
|
||||
}
|
||||
|
||||
private async fetchHostPublicKey(host: string, port?: string): Promise<string> {
|
||||
const portArgs = port ? ['-p', port] : []
|
||||
const output = await executeCommand(['ssh-keyscan', '-t', 'ed25519,rsa,ecdsa', ...portArgs, host], { silent: true })
|
||||
|
||||
const result = await executeCommand(
|
||||
['ssh-keyscan', '-t', 'ed25519,rsa,ecdsa', ...portArgs, host],
|
||||
{ silent: true, ignoreExitCode: true }
|
||||
)
|
||||
const output = (result as unknown as { stdout: string }).stdout
|
||||
const bracketedHost = port && port !== '22' ? `[${host}]:${port}` : host
|
||||
const lines = output.trim().split('\n')
|
||||
for (const line of lines) {
|
||||
|
||||
Reference in new issue
Block a user