-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/crypto/ssh: Signal method doesn't work #16597
Comments
This might be related to #4115 in any case this should be fixed :) |
ssh signal just sends a request with the signal name to the other side, so there is little that can break on the cliet side. Can you provide proof that signals do work in other client implementations with this server? |
On Mon, Aug 8, 2016 at 5:55 AM, Han-Wen Nienhuys notifications@github.com
It's a good question, but I don't know the answer. I do know that running |
"exec killall" doesn't work when there is a restrictions on running commands (eg. ProgramName critical option in certs), so I don't think we should offer this is as a default workaround. It would be great if you could get to the bottom of this, so we understand the problem fully before we document anything. I suspect openssh disables signals by default, and that they have some good reason for it. |
It looks to me like OpenSSH doesn't support this on the server side, it's in the protocol documentation, but unimplemented.
|
@spudlyo Great find, thanks. Anyone have friends upstream there that can get that merged? |
Ping? Anybody know who the maintainer for this is? |
I have asked about the open ticket a couple times in the last few months and never got a reply. https://marc.info/?l=openssh-unix-dev&m=151872213119286&w=2 |
I'm hitting this too. |
God I though that was my code's problem... |
As I've discovered elsewhere, sending |
@MikaelSmith Not always. For example, when cancelling |
It looks like the fix was finally integrated into openssh version 7.9: https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/session.c.diff?r1=1.305&r2=1.306&f=h though I haven't verified yet that it works. |
I was able to verify that this issue is resolved in OpenSSH 1.7.9 by running the following code against two versions of sshd on Ubuntu 18.04 LTS (bionic). package main
import (
"io"
"log"
"os"
"time"
"golang.org/x/crypto/ssh"
)
func main() {
// Create client config
config := &ssh.ClientConfig{
User: "XXXX",
Auth: []ssh.AuthMethod{
ssh.Password("XXXX"),
},
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
}
// Connect to ssh server
conn, err := ssh.Dial("tcp", "localhost:2222", config)
if err != nil {
log.Fatal("unable to connect: ", err)
}
defer conn.Close()
// Create a session
session, err := conn.NewSession()
if err != nil {
log.Fatal("unable to create session: ", err)
}
defer session.Close()
stdout, err := session.StdoutPipe()
if err != nil {
log.Fatal(err)
}
stderr, err := session.StderrPipe()
if err != nil {
log.Fatal(err)
}
command := `/bin/bash -c 'catch_interrupt() { echo \"caught SIGINT!\"; sleep 2; } ;
trap catch_interrupt INT && ssh -V && sleep 5 && echo "no signal caught"'`
if err := session.Start(command); err != nil {
log.Fatal(err)
}
go func() {
io.Copy(os.Stderr, stderr)
}()
go func() {
io.Copy(os.Stdout, stdout)
}()
go func() {
time.Sleep(2 * time.Second)
log.Println("sending signal: ")
if err := session.Signal(ssh.SIGINT); err != nil {
log.Fatal(err)
}
log.Println("signal sent")
}()
if err := session.Wait(); err != nil {
log.Println(err)
}
} Running against Ubuntu Bionic (18.04 LTS) openssh-server 1.7.6
Again with pinned Ubuntu Disco(19.04) package openssh-server 1.7.9
|
thanks for verifying. .Since this is not a problem in the Go library, and openssh fixed their problem, I'm closing the bug. |
does anyone has any suggestion how can I send the signal to remote when I can't update the openssh to 1.7.9 on server? |
Starting a process over SSH using the /x/crypto/ssh library and then trying to send a signal to it, seems to have no effect. I've found a few musings on the internet about users with the same problem.
I've attached a full reproducer, including the crappy workaround.
Uncomment the signal you want, and you'll see that they all do nothing to kill the running
sleep
command.Tested with go version: 1.5.4 (but I have no reason to expect this is fixed with newer versions!) on Fedora GNU/Linux 24 as the SSH server, running OpenSSH.
Thanks!
The text was updated successfully, but these errors were encountered: