Search code examples
bashsshsshpass

Empty ssh invitation (no "user@host:~$") when run command after connect (sh script, sshpass)


Client OS: MacOS 12.1, Server OS: Linux Debian 9 (any server)

case 1:

#!/bin/bash
sshpass -p mypass ssh user@host.ru -o StrictHostKeyChecking=no

works fine: enter image description here

case 2:

#!/bin/bash
sshpass -p mypass ssh user@host.ru -o StrictHostKeyChecking=no "cd /var/www ; git status ; /bin/bash"

enter image description here Output of "git status" works fine, but no "user@host:~$" message in output (input is active).

I tried: /bin/bash bash -l (in server "echo $SHELL" shows /bin/bash)

How to fix it?


Solution

  • Use ssh -t and && inside commands list

    #!/bin/bash
    sshpass -p mypass ssh -t user@host.ru -o StrictHostKeyChecking=no "cd /var/www && git status && /bin/bash"