add PTY handler

This commit is contained in:
2025-11-06 23:42:56 +01:00
parent 25f29e2dc4
commit 3ec2b90315
2 changed files with 21 additions and 12 deletions

View File

@@ -33,9 +33,9 @@ jobs:
run: |
ip=$(docker inspect ssh-server-test | jq -r '.[0].NetworkSettings.Networks."test-net".IPAddress')
echo "Server IP: $ip"
output=$( { docker run --rm --network test-net alpine sh -c "apk add --no-cache openssh-client && ssh -p 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 root@$ip 'echo test559920'" ; } 2>&1 ; true )
output=$( { docker run --rm --network test-net alpine sh -c "apk add --no-cache openssh-client && timeout 5 ssh -t -p 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 root@$ip" ; } 2>&1 ; true )
echo "Captured output: '$output'"
if echo "$output" | grep -q "test559920"; then
if echo "$output" | grep -q "Welcome to"; then
echo "SSH connection test passed"
else
echo "SSH connection test failed: $output"

View File

@@ -225,6 +225,15 @@ func main() {
}
func teaHandler(s ssh.Session) (tea.Model, []tea.ProgramOption) {
// Check if PTY is available
ptyReq, _, _ := s.Pty()
if ptyReq.Term == "" {
// No PTY, handle as command execution
s.Write([]byte("This server requires an interactive terminal (PTY).\nPlease connect with: ssh -t user@host\n"))
s.Exit(1)
return nil, nil
}
return model{
showWelcome: true,
focus: 0,