Ethical Hacking Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package. | Computer Forensics Training at InfoSec Institute Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors. |

| Subject: | Re: Closing a process when SSH is interrupted? |
|---|---|
| Date: | Tue, 20 Nov 2007 20:54:39 +0000 |
I've just run across this problem too using Solaris openssh-4.4p1. I have learned that using 'trap' is no help because the spawned shell never receives any signal or Ctrl-C. Its parent sshd detects the end of the network connection and abandons the spawned shell without notice. One work around I found is to use 'ssh -t' to invoke the remote command. This forces the spawned shell to have a controlling terminal. Invoked this way, the remote command is correctly interrupted and terminated as you would like. This doesn't seem like the correct behavior. With or without a controlling terminal, the remote command should be terminated. I've submitted this question to openssh-unix-dev. Mark Glemboski --- begin included message --- an ssh session spawns a remote shell, which is hopefully Bash. Have you tried using traps to mop up your application on exit rather than letting it be orphaned to init? trap "kill someprocess" SIGNAL1 SIGNAL2 etc... see man bash for details... or whatever your shell's man page is. -h Hari Sekhon Jared C. Davis wrote:
Hi, Is there a way to tell SSH that the remote task should be killed once the client disconnects? For example, I tried running: me@local$ ssh remote sleep 100 And then typed [Ctrl+C] to kill the ssh command on local. But the sleep command kept running on remote for the full 100 seconds. I think I want to be able to tell the remote machine, "if I interrupt the ssh client, then kill the process I sent you." Maybe I should be doing something else. I'm working on a script that uses SSH to send some commands to remote machines, but sometimes these
commands can get into infinite loops and need to be killed. When this
happens, I'd like to be able to have my program kill them. It seemed most straightforward to kill the ssh client, but then I discovered this does not kill the remote process. Thanks! Jared
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: Defering passphrase entry with ssh-add, Christopher Key |
|---|---|
| Next by Date: | Re: Restricted (ksh -r) shell and SSH on AIX5.1, Jeremy C. Reed |
| Previous by Thread: | Restricted (ksh -r) shell and SSH on AIX5.1, Rob Sherry |
| Next by Thread: | company puts a new spin on infosec services, im obfuscated |
| Indexes: | [Date] [Thread] [Top] [All Lists] |