Skip to main content
added 329 characters in body
Source Link
Ole Tange
  • 37.5k
  • 34
  • 119
  • 226

I want to be able to send signals (SIGINT is the most important) through ssh.

This command:

ssh server "sleep 1000;echo f" > foo

will start sleep on server and after 1000 seconds it will put 'f\n' in the file foo on my local machine. If I press CTRL-C (i.e. send SIGINT to ssh) it will kill ssh, but it will not kill sleep on the remote server. I want it to kill sleep on the remote server.

So I tried:

ssh server -t "sleep 1000;echo f" > foo

But if stdin is not a terminal I get this error:

Pseudo-terminal will not be allocated because stdin is not a terminal.

and then SIGINT is still not forwarded.

So I tried:

ssh server -t -t "sleep 1000;echo f" > output

But then the output in foo is not 'f\n' but instead 'f\r\n' which is disastrous in my situation (as my output is binary data).

In the above I use "sleep 1000;echo f", but in reality that is supplied by the user, thus it can contain anything. However, if we can make it work for "sleep 1000;echo f" we can most likely make it work for all realistic situations.

I really do not care about getting a pseudo-terminal at the other end, but I have been unable to find any other way of getting ssh to forward my SIGINT.

Is there another way?

Edit:

The user could give commands that read binary data from stdin, such as:

seq 1000 | gzip | ssh server "zcat|bzip2; sleep 1000" | bzcat > foo

The user could give commands that are cpu intensive, such as:

ssh server "timeout 1000 burnP6"

Edit2:

The version that seems to work for me is:

your_preprocessing |
  uuencode a | ssh -tt -oLogLevel=quiet server "stty isig -echoctl -echo ; uudecode -o - |
your_command |
  uuencode a" | uudecode -o - |
your_postprocessing

Thanks to digital_infinity for pointing me in the right direction.

I want to be able to send signals (SIGINT is the most important) through ssh.

This command:

ssh server "sleep 1000;echo f" > foo

will start sleep on server and after 1000 seconds it will put 'f\n' in the file foo on my local machine. If I press CTRL-C (i.e. send SIGINT to ssh) it will kill ssh, but it will not kill sleep on the remote server. I want it to kill sleep on the remote server.

So I tried:

ssh server -t "sleep 1000;echo f" > foo

But if stdin is not a terminal I get this error:

Pseudo-terminal will not be allocated because stdin is not a terminal.

and then SIGINT is still not forwarded.

So I tried:

ssh server -t -t "sleep 1000;echo f" > output

But then the output in foo is not 'f\n' but instead 'f\r\n' which is disastrous in my situation (as my output is binary data).

In the above I use "sleep 1000;echo f", but in reality that is supplied by the user, thus it can contain anything. However, if we can make it work for "sleep 1000;echo f" we can most likely make it work for all realistic situations.

I really do not care about getting a pseudo-terminal at the other end, but I have been unable to find any other way of getting ssh to forward my SIGINT.

Is there another way?

Edit:

The user could give commands that read binary data from stdin, such as:

seq 1000 | gzip | ssh server "zcat|bzip2; sleep 1000" | bzcat > foo

The user could give commands that are cpu intensive, such as:

ssh server "timeout 1000 burnP6"

I want to be able to send signals (SIGINT is the most important) through ssh.

This command:

ssh server "sleep 1000;echo f" > foo

will start sleep on server and after 1000 seconds it will put 'f\n' in the file foo on my local machine. If I press CTRL-C (i.e. send SIGINT to ssh) it will kill ssh, but it will not kill sleep on the remote server. I want it to kill sleep on the remote server.

So I tried:

ssh server -t "sleep 1000;echo f" > foo

But if stdin is not a terminal I get this error:

Pseudo-terminal will not be allocated because stdin is not a terminal.

and then SIGINT is still not forwarded.

So I tried:

ssh server -t -t "sleep 1000;echo f" > output

But then the output in foo is not 'f\n' but instead 'f\r\n' which is disastrous in my situation (as my output is binary data).

In the above I use "sleep 1000;echo f", but in reality that is supplied by the user, thus it can contain anything. However, if we can make it work for "sleep 1000;echo f" we can most likely make it work for all realistic situations.

I really do not care about getting a pseudo-terminal at the other end, but I have been unable to find any other way of getting ssh to forward my SIGINT.

Is there another way?

Edit:

The user could give commands that read binary data from stdin, such as:

seq 1000 | gzip | ssh server "zcat|bzip2; sleep 1000" | bzcat > foo

The user could give commands that are cpu intensive, such as:

ssh server "timeout 1000 burnP6"

Edit2:

The version that seems to work for me is:

your_preprocessing |
  uuencode a | ssh -tt -oLogLevel=quiet server "stty isig -echoctl -echo ; uudecode -o - |
your_command |
  uuencode a" | uudecode -o - |
your_postprocessing

Thanks to digital_infinity for pointing me in the right direction.

added 103 characters in body
Source Link
Ole Tange
  • 37.5k
  • 34
  • 119
  • 226

I want to be able to send signals (SIGINT is the most important) through ssh.

This command:

ssh server "sleep 1000;echo f" > foo

will start sleep on server and after 1000 seconds it will put 'f\n' in the file foo on my local machine. If I press CTRL-C (i.e. send SIGINT to ssh) it will kill ssh, but it will not kill sleep on the remote server. I want it to kill sleep on the remote server.

So I tried:

ssh server -t "sleep 1000;echo f" > foo

But if stdin is not a terminal I get this error:

Pseudo-terminal will not be allocated because stdin is not a terminal.

and then SIGINT is still not forwarded.

So I tried:

ssh server -t -t "sleep 1000;echo f" > output

But then the output in foo is not 'f\n' but instead 'f\r\n' which is disastrous in my situation (as my output is binary data).

In the above I use "sleep 1000;echo f", but in reality that is supplied by the user, thus it can contain anything. However, if we can make it work for "sleep 1000;echo f" we can most likely make it work for all realistic situations.

I really do not care about getting a pseudo-terminal at the other end, but I have been unable to find any other way of getting ssh to forward my SIGINT.

Is there another way?

Edit:

The user could give commands that read binary data from stdin, such as:

seq 1000 | gzip | ssh server "zcat|bzip2; sleep 1000" | bzcat > foo

The user could give commands that are cpu intensive, such as:

ssh server "timeout 1000 burnP6"

I want to be able to send signals (SIGINT is the most important) through ssh.

This command:

ssh server "sleep 1000;echo f" > foo

will start sleep on server and after 1000 seconds it will put 'f\n' in the file foo on my local machine. If I press CTRL-C (i.e. send SIGINT to ssh) it will kill ssh, but it will not kill sleep on the remote server. I want it to kill sleep on the remote server.

So I tried:

ssh server -t "sleep 1000;echo f" > foo

But if stdin is not a terminal I get this error:

Pseudo-terminal will not be allocated because stdin is not a terminal.

and then SIGINT is still not forwarded.

So I tried:

ssh server -t -t "sleep 1000;echo f" > output

But then the output in foo is not 'f\n' but instead 'f\r\n' which is disastrous in my situation (as my output is binary data).

In the above I use "sleep 1000;echo f", but in reality that is supplied by the user, thus it can contain anything. However, if we can make it work for "sleep 1000;echo f" we can most likely make it work for all realistic situations.

I really do not care about getting a pseudo-terminal at the other end, but I have been unable to find any other way of getting ssh to forward my SIGINT.

Is there another way?

Edit:

The user could give commands that read binary data from stdin, such as:

seq 1000 | gzip | ssh server "zcat|bzip2; sleep 1000" | bzcat > foo

I want to be able to send signals (SIGINT is the most important) through ssh.

This command:

ssh server "sleep 1000;echo f" > foo

will start sleep on server and after 1000 seconds it will put 'f\n' in the file foo on my local machine. If I press CTRL-C (i.e. send SIGINT to ssh) it will kill ssh, but it will not kill sleep on the remote server. I want it to kill sleep on the remote server.

So I tried:

ssh server -t "sleep 1000;echo f" > foo

But if stdin is not a terminal I get this error:

Pseudo-terminal will not be allocated because stdin is not a terminal.

and then SIGINT is still not forwarded.

So I tried:

ssh server -t -t "sleep 1000;echo f" > output

But then the output in foo is not 'f\n' but instead 'f\r\n' which is disastrous in my situation (as my output is binary data).

In the above I use "sleep 1000;echo f", but in reality that is supplied by the user, thus it can contain anything. However, if we can make it work for "sleep 1000;echo f" we can most likely make it work for all realistic situations.

I really do not care about getting a pseudo-terminal at the other end, but I have been unable to find any other way of getting ssh to forward my SIGINT.

Is there another way?

Edit:

The user could give commands that read binary data from stdin, such as:

seq 1000 | gzip | ssh server "zcat|bzip2; sleep 1000" | bzcat > foo

The user could give commands that are cpu intensive, such as:

ssh server "timeout 1000 burnP6"
Explained the user might give command reading from stdin
Source Link
Ole Tange
  • 37.5k
  • 34
  • 119
  • 226

I want to be able to send signals (SIGINT is the most important) through ssh.

This command:

ssh server "sleep 1000;echo f" > foo

will start sleep on server and after 1000 seconds it will put 'f\n' in the file foo on my local machine. If I press CTRL-C (i.e. send SIGINT to ssh) it will kill ssh, but it will not kill sleep on the remote server. I want it to kill sleep on the remote server.

So I tried:

ssh server -t "sleep 1000;echo f" > foo

But if stdin is not a terminal I get this error:

Pseudo-terminal will not be allocated because stdin is not a terminal.

and then SIGINT is still not forwarded.

So I tried:

ssh server -t -t "sleep 1000;echo f" > output

But then the output in foo is not 'f\n' but instead 'f\r\n' which is disastrous in my situation (as my output is binary data).

In the above I use "sleep 1000;echo f", but in reality that is supplied by the user, thus it can contain anything. However, if we can make it work for "sleep 1000;echo f" we can most likely make it work for all realistic situations.

I really do not care about getting a pseudo-terminal at the other end, but I have been unable to find any other way of getting ssh to forward my SIGINT.

Is there another way?

Edit:

The user could give commands that read binary data from stdin, such as:

seq 1000 | gzip | ssh server "zcat|bzip2; sleep 1000" | bzcat > foo

I want to be able to send signals (SIGINT is the most important) through ssh.

This command:

ssh server "sleep 1000;echo f" > foo

will start sleep on server and after 1000 seconds it will put 'f\n' in the file foo on my local machine. If I press CTRL-C (i.e. send SIGINT to ssh) it will kill ssh, but it will not kill sleep on the remote server. I want it to kill sleep on the remote server.

So I tried:

ssh server -t "sleep 1000;echo f" > foo

But if stdin is not a terminal I get this error:

Pseudo-terminal will not be allocated because stdin is not a terminal.

and then SIGINT is still not forwarded.

So I tried:

ssh server -t -t "sleep 1000;echo f" > output

But then the output in foo is not 'f\n' but instead 'f\r\n' which is disastrous in my situation (as my output is binary data).

In the above I use "sleep 1000;echo f", but in reality that is supplied by the user, thus it can contain anything. However, if we can make it work for "sleep 1000;echo f" we can most likely make it work for all realistic situations.

I really do not care about getting a pseudo-terminal at the other end, but I have been unable to find any other way of getting ssh to forward my SIGINT.

Is there another way?

I want to be able to send signals (SIGINT is the most important) through ssh.

This command:

ssh server "sleep 1000;echo f" > foo

will start sleep on server and after 1000 seconds it will put 'f\n' in the file foo on my local machine. If I press CTRL-C (i.e. send SIGINT to ssh) it will kill ssh, but it will not kill sleep on the remote server. I want it to kill sleep on the remote server.

So I tried:

ssh server -t "sleep 1000;echo f" > foo

But if stdin is not a terminal I get this error:

Pseudo-terminal will not be allocated because stdin is not a terminal.

and then SIGINT is still not forwarded.

So I tried:

ssh server -t -t "sleep 1000;echo f" > output

But then the output in foo is not 'f\n' but instead 'f\r\n' which is disastrous in my situation (as my output is binary data).

In the above I use "sleep 1000;echo f", but in reality that is supplied by the user, thus it can contain anything. However, if we can make it work for "sleep 1000;echo f" we can most likely make it work for all realistic situations.

I really do not care about getting a pseudo-terminal at the other end, but I have been unable to find any other way of getting ssh to forward my SIGINT.

Is there another way?

Edit:

The user could give commands that read binary data from stdin, such as:

seq 1000 | gzip | ssh server "zcat|bzip2; sleep 1000" | bzcat > foo
Tweeted twitter.com/#!/StackUnix/status/209830676336349184
Explained that "sleep 1000;echo f" is only an example.
Source Link
Ole Tange
  • 37.5k
  • 34
  • 119
  • 226
Loading
Source Link
Ole Tange
  • 37.5k
  • 34
  • 119
  • 226
Loading