Start SSH connection in PuTTY, run a command, and leave the session active

后端 未结 2 1690
轮回少年
轮回少年 2020-12-19 12:27

I want to run a few shell commands every time I SSH to a server via PuTTY. I\'m connecting to a production web server managed by someone else, and I don\'t want to store my

相关标签:
2条回答
  • 2020-12-19 13:18

    The SSH session closes (and PuTTY with it) as soon as the command finishes. By default the "command" is a shell. As you have overridden this default "command" and yet you want to run the shell nevertheless, you have to explicitly execute the shell yourself:

    my-command ; /bin/bash
    

    See also Executing a specific command on the server.

    0 讨论(0)
  • 2020-12-19 13:26

    One option to go is set up your putty remote command like this:

    ls > dir.ls & /bin/bash
    

    In this example command you want to run is "ls > dir.ls" what creates file dir.ls with content of directory listing.

    And as you want to leave shell open you can add aditional command "/bin/bash" or any other shell of your choice.

    0 讨论(0)
提交回复
热议问题