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:
Chris Scott authored and GitHub committed 2026-02-11 22:58:13 -05:00
1 parent 677ce748cd
commit 7341dce1ef
25 files changed
+203 -123

No files matched your search

+39 -3
View File
@@ -16,14 +16,21 @@ export function AddRepoDialog({ open, onOpenChange }: AddRepoDialogProps) {
const [repoUrl, setRepoUrl] = useState('')
const [localPath, setLocalPath] = useState('')
const [branch, setBranch] = useState('')
const [skipSSHVerification, setSkipSSHVerification] = useState(false)
const queryClient = useQueryClient()
const isSSHUrl = (url: string): boolean => {
return url.startsWith('git@') || url.startsWith('ssh://')
}
const showSkipSSHCheckbox = repoType === 'remote' && isSSHUrl(repoUrl)
const mutation = useMutation({
mutationFn: () => {
if (repoType === 'local') {
return createRepo(undefined, localPath, branch || undefined, undefined, false)
} else {
return createRepo(repoUrl, undefined, branch || undefined, undefined, false)
return createRepo(repoUrl, undefined, branch || undefined, undefined, false, skipSSHVerification)
}
},
onSuccess: () => {
@@ -32,6 +39,7 @@ export function AddRepoDialog({ open, onOpenChange }: AddRepoDialogProps) {
setLocalPath('')
setBranch('')
setRepoType('remote')
setSkipSSHVerification(false)
onOpenChange(false)
},
})
@@ -43,6 +51,13 @@ export function AddRepoDialog({ open, onOpenChange }: AddRepoDialogProps) {
}
}
const handleRepoUrlChange = (value: string) => {
setRepoUrl(value)
if (!isSSHUrl(value)) {
setSkipSSHVerification(false)
}
}
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="sm:max-w-[500px] bg-[#141414] border-[#2a2a2a]">
@@ -88,7 +103,7 @@ export function AddRepoDialog({ open, onOpenChange }: AddRepoDialogProps) {
<Input
placeholder="owner/repo or https://github.com/user/repo.git"
value={repoUrl}
onChange={(e) => setRepoUrl(e.target.value)}
onChange={(e) => handleRepoUrlChange(e.target.value)}
disabled={mutation.isPending}
className="bg-[#1a1a1a] border-[#2a2a2a] text-white placeholder:text-zinc-500"
/>
@@ -136,7 +151,28 @@ export function AddRepoDialog({ open, onOpenChange }: AddRepoDialogProps) {
}
</p>
</div>
{showSkipSSHCheckbox && (
<div className="flex items-start space-x-2">
<input
type="checkbox"
id="skip-ssh-verification"
checked={skipSSHVerification}
onChange={(e) => setSkipSSHVerification(e.target.checked)}
disabled={mutation.isPending}
className="mt-1 h-4 w-4 rounded border-[#2a2a2a] bg-[#1a1a1a] text-blue-600 focus:ring-blue-600"
/>
<div className="flex-1">
<label htmlFor="skip-ssh-verification" className="cursor-pointer text-sm text-white">
Skip SSH host key verification
</label>
<p className="text-xs text-zinc-500">
Auto-accept the SSH host key. Use for self-hosted or internal Git servers.
</p>
</div>
</div>
)}
<Button
type="submit"
disabled={(!repoUrl && repoType === 'remote') || (!localPath && repoType === 'local') || mutation.isPending}
@@ -25,7 +25,7 @@ export function GitCredentialDialog({ open, onOpenChange, onSave, credential, is
token: '',
username: '',
sshPrivateKey: '',
passphrase: '',
passphrase: ''
})
const [tokenEdited, setTokenEdited] = useState(false)
const [isTesting, setIsTesting] = useState(false)
@@ -238,12 +238,12 @@ export function GitSettings() {
<td className="px-3 py-2 text-muted-foreground hidden sm:table-cell">
{cred.host}
</td>
<td className="px-3 py-2 text-muted-foreground hidden sm:table-cell">
<span className="text-xs px-1.5 py-0.5 rounded bg-muted">
{cred.type === 'ssh' ? 'SSH' : 'PAT'}
</span>
</td>
<td className="px-3 py-2">
<td className="px-3 py-2 text-muted-foreground hidden sm:table-cell">
<span className="text-xs px-1.5 py-0.5 rounded bg-muted">
{cred.type === 'ssh' ? 'SSH' : 'PAT'}
</span>
</td>
<td className="px-3 py-2">
<div className="flex items-center justify-end gap-1">
<Button
type="button"
@@ -12,9 +12,11 @@ import { Alert, AlertDescription } from '@/components/ui/alert'
import { CopyButton } from '@/components/ui/copy-button'
import { Shield, ShieldAlert } from 'lucide-react'
import { cn } from '@/lib/utils'
import type { SSHHostKeyRequest, SSHHostKeyResponse } from '@/api/types'
import type { SSHHostKeyRequest } from '@/api/types'
import { showToast } from '@/lib/toast'
type SSHHostKeyResponse = 'accept' | 'reject'
interface SSHHostKeyDialogProps {
request: SSHHostKeyRequest | null
onRespond: (requestId: string, response: SSHHostKeyResponse) => Promise<void>
@@ -100,7 +102,7 @@ export function SSHHostKeyDialog({
</DialogDescription>
</DialogHeader>
<div className="space-y-3">
<div className="space-y-4">
{request.isKeyChanged && (
<Alert variant="destructive">
<AlertDescription className="text-sm">