linuxbashsshputtyserver-administration

Is it possible to run multiple command with remote command option in putty?


I want to run multiple commands automatically like sudo bash, ssh server01, ls , cd /tmp etc at server login.. I am using Remote command option under SSH in putty.

I tried multiple commands with delimiter && but not working.

enter image description here


Solution

  • There is a some information lacking in your question.

    You say you want to run sudo bash, then ssh server01.

    Will sudo prompt for a password in your remote server?

    Assuming there is no password in sudo, running bash will open another shell waiting for user input. The command ssh server01 will not be run until that bash shell is exited.

    If you want to run 2 commands, try first simpler ones like:

    ls -l /tmp ; echo "hi there"
    

    or if you prefer:

    ls -l /tmp && echo "hi there"
    

    Does this work?

    If what you want is to run ssh after running bash, you can try :

    sudo bash -c "ssh server01"