add PTY handler
This commit is contained in:
@@ -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"
|
||||
|
||||
9
main.go
9
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,
|
||||
|
||||
Reference in New Issue
Block a user