Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

Automatic kill of user gust connection, via ssh

  1. In former page I suggested a nice way to connect the office machine to home, via ssh. Remote Connecting To Work Computer - main page.

  2. The remote connect script, which runs on the office machines, knows how to reconnect. However when IP changes, I need sometime to manually kill the connection, from the machine at home. This in turn triggers the script at work to re-connect.

  3. The office machine uses a reduced permission user account for guests. To kill the connection, I need to be either super user or enter the guest user. Since I usually don't remember the gust password, I do it as super user. I use a script to automate the process and avoid stupid mistakes.
    Note: that although the script is run from the super user, it kills only process of a specific user.

    #!/bin/bash

    #guestA 28530 28511 0 13:34 ? 00:00:00 sshd: guestA@pts/8
    #guestA 28515 28513 0 13:34 ? 00:00:00 sshd: guestA@pts/5

    for f in $(ps -aefH | grep "^guestA.*ssh" | sed 's/guestA *\([0-9]*\) *\([0-9]*\).*/\1/'); do
      cmd="kill "$f
      echo $cmd
      $cmd
    done


  ...



Home

Download Area






Search This Site


Feedback This Site




new pages on this site