When the connection is slow, I connect to remote computers using SSH without allocating a pseudo-terminal (e.g. ssh -T user@example.com or ssh user@example.com bash). Although I am able to use the shell, the shell does not display a prompt. Is there a way to make the shell display a prompt (e.g. $ ) when connecting via SSH without a pseudo-terminal?

I could run the bash script below on the remote computer, but I'm wondering if there is something built-in that I can use to get a prompt.

# or #!/bin/sh

PS='$ '

prompt() {
    printf '%s' "$PS"
    read -r line
    # Exit if EOF (Ctrl-d).
    [ "$?" -ne 0 ] && echo && exit
    eval "$line"

# Handle Ctrl-c.
trap 'echo && prompt' INT

while :

(Adapted based on: https://tldp.org/LDP/abs/html/intandnonint.html)

This script has the disadvantage that it is not able to handle multi-line inputs.

  • @terdon if you're using ssh over a line with 500ms latency, it would take >1second every time you press a key until it appears on the screen. That's not an XY problem --- it actually makes the ssh unusable.
    – user313992
    Nov 10, 2021 at 14:28
  • @UncleBilly oh yes, I am painfully aware of that problem. I just don't know if disabling the pseudo-tty allocation is actually that helpful. The XY would be if the -T option isn't actually helping much. Does it? Do you know? Happily I no longer need to deal with such slow connections these days so I can't test.
    – terdon
    Nov 10, 2021 at 14:42
  • 1
    @terdon when the pty allocation is disabled, ssh does not set the local tty to raw mode, and typing in a 80-characters command line turns into a single packet + response instead of 80.
    – user313992
    Nov 10, 2021 at 14:46
  • Ah, I see. Thanks, @UncleBilly.
    – terdon
    Nov 10, 2021 at 14:54

1 Answer 1


It obviously does not solve all problems which result from the missing tty but you can do this:

ssh -T user@example.com bash -i
  • This also works for /bin/sh.
    – Flux
    Nov 12, 2021 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.