Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Add Comment to SSH process

Options
  • 10-02-2014 4:13pm
    #1
    Registered Users Posts: 1,477 ✭✭✭


    This calls for either some lateral thinking or for one of you guys to point out the blinding obvious!

    I need to fork an SSH process or a batch of processes. And then I need to be able to kill them, uniquely. The forking takes place via a web interface and although I could get the pid of each process I rather not have multiple pid files hanging about. Even then it would be tricky to match pid with process. I was hoping there might a way to add a comment to the SSH process (ssh_config(5) list some promising switches but none I can use) What I was hoping for was something like:
    ssh user@host -i $file -p $port -oComment="My Unique Comment"
    

    Then, if I:
    ps -ef |grep "My Unique Comment" |grep -v grep | awk {'print $2'}
    
    I can grab the pid and kill as required. Any tips!?


Comments

  • Registered Users Posts: 53 ✭✭spynappels


    Would it be possible to open each in a separate screen instance with a specific name and then you can kill the screen processes based on their name/comment?


  • Closed Accounts Posts: 18,966 ✭✭✭✭syklops


    azzeretti wrote: »
    This calls for either some lateral thinking or for one of you guys to point out the blinding obvious!

    I need to fork an SSH process or a batch of processes. And then I need to be able to kill them, uniquely. The forking takes place via a web interface and although I could get the pid of each process I rather not have multiple pid files hanging about. Even then it would be tricky to match pid with process. I was hoping there might a way to add a comment to the SSH process (ssh_config(5) list some promising switches but none I can use) What I was hoping for was something like:
    ssh user@host -i $file -p $port -oComment="My Unique Comment"
    

    Then, if I:
    ps -ef |grep "My Unique Comment" |grep -v grep | awk {'print $2'}
    
    I can grab the pid and kill as required. Any tips!?

    How about instead of a unique comment, you create a uniquely named config file for each ssh session. The contents of the config file can remain the same, but the name of the file will be unique. The you can do a ps aux | grep 'unique name", to kill it.


  • Registered Users Posts: 1,477 ✭✭✭azzeretti


    syklops wrote: »
    How about instead of a unique comment, you create a uniquely named config file for each ssh session. The contents of the config file can remain the same, but the name of the file will be unique. The you can do a ps aux | grep 'unique name", to kill it.

    I like this! Good thinking.
    Thanks.


Advertisement