diff --git a/.gitea/workflows/build-and-push.yml b/.gitea/workflows/build-and-push.yml index eeb720e..ff70d3b 100644 --- a/.gitea/workflows/build-and-push.yml +++ b/.gitea/workflows/build-and-push.yml @@ -29,18 +29,18 @@ jobs: exit 1 fi - - name: Test SSH connection - 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 ) - echo "Captured output: '$output'" - if echo "$output" | grep -q "test559920"; then - echo "SSH connection test passed" - else - echo "SSH connection test failed: $output" - exit 1 - fi + - name: Test SSH connection + 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 && 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 "Welcome to"; then + echo "SSH connection test passed" + else + echo "SSH connection test failed: $output" + exit 1 + fi docker stop ssh-server-test && docker rm ssh-server-test && docker network rm test-net build-and-push: diff --git a/main.go b/main.go index daca39b..552b3f0 100644 --- a/main.go +++ b/main.go @@ -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,