Find the answer to your Linux question:
Results 1 to 3 of 3
I have to make an non-interactive script that will handle some files on an remote computer. This is not a problem if I use ssh-agent and RSA keys (and this ...
  1. #1
    Just Joined!
    Join Date
    Jul 2007
    Posts
    2

    Ssh

    I have to make an non-interactive script that will handle some files on an remote computer. This is not a problem if I use ssh-agent and RSA keys (and this is ok because computers are servers, meaning that are almost allways on). But, if somehow i lose key (or server is restarted) then ssh will ask for passphrase... Then I need to detect that and inform an admin... How can I do that ??? How to kill ssh login if passphrase is't provided for, let's say, 10 sec ??

    Thanks!

    Regards,
    Raul.B

  2. #2
    Linux Enthusiast
    Join Date
    Apr 2004
    Location
    UK
    Posts
    658
    I'm not sure you can do this directly with ssh, however you could use expect to do it. You could even use it to fire off a script to email the admin if there is unexpected behaviour.

    Let us know how you get on,

    Chris...
    To be good, you must first be bad. "Newbie" is a rank, not a slight.

  3. #3
    Just Joined!
    Join Date
    Jul 2007
    Posts
    2

    solved...

    I did it... some threads experience from C gave me an ideea. Before trying to log with ssh I call a function (wich i wrote at the beginning of the script) containing an sleep command and put that function in background. Then i try to log with ssh and, if ssh succed then comes a command that makes a file named FLAG, and if ssh fails.... well it remains stuck so no file is created. In midtime sleep from background function "expires" and next command in function is executed, command which checks if FILE exists. If it does then it's all OK, if it doesn't, that means ssh faild, and then comes an KILL -9 $$ and script is closed (that was my intention in case ssh fails). It's important tu use KILL because an ordinary exit won't do the job, SSH will still remain stuck, cause it haves it's own PID... i think... i didn't checked it

    Anyway.... thanks for reply...

    Regards,
    Raul.B

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...