[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1052451: openssh-client: Ctrl-C kills ssh but not ssh-add, which steals input from the terminal



Control: retitle -1 openssh-client: Ctrl-C does not kill a ssh-add run from a script

(No issues with ssh-add is run directly from the shell, see below.)

On 2023-09-22 12:18:24 +0200, Vincent Lefevre wrote:
> On 2023-09-22 12:10:19 +0200, Vincent Lefevre wrote:
> > On 2023-09-22 11:28:12 +0200, Vincent Lefevre wrote:
> > > It seems that that ssh command runs ssh-add automatically.

That's actually a ssh wrapper I use that does that. I thought that
the wrapper was not involved here because it was no longer running.
What happens is that the Ctrl-C seems to kill the wrapper (thus ssh
and unison terminate too, returning to mutt), but not ssh-add, hence
the issue.

A possibly important point: I call ssh-add with several files in
argument, and a Ctrl-C aborts the first passphrase, but ssh-add is
still running for the other passphrases, which is bad.

An example:

cventin:~> unison mail -root "ssh://joooj/Mail"
Unison 2.53.3 (ocaml 4.13.1): Contacting server...
Enter passphrase for /home/vlefevre/.ssh/id_rsa: 

"ps -fu vlefevre" shows in particular:

vlefevre   54481   54467  0 13:50 pts/4    00:00:00 cat
vlefevre   54483   54467  0 13:50 pts/4    00:00:00 ssh-add /home/vlefevre/.ssh/id_rsa /home/vlefevre/.ssh/id_rsa-and

(the long line is truncated).

Now I type Ctrl-C, which gives:

Enter passphrase for /home/vlefevre/.ssh/id_rsa: Terminated!
cventin:~[3]>                                                         <13:50:24

and "ps -fu vlefevre":

vlefevre   54481       1  0 13:50 pts/4    00:00:00 cat
vlefevre   54483       1  0 13:50 pts/4    00:00:00 ssh-add /home/vlefevre/.ssh/id_rsa /home/vlefevre/.ssh/id_rsa-and

These processes are now attached to pid 1, with still pts/4 as
the associated terminal.

If I type any character, ssh-add receives the key as the following
is output:

Enter passphrase for /home/vlefevre/.ssh/id_rsa-android: 
Enter passphrase for /home/vlefevre/.ssh/id_rsa-cfarm: 
[...]

and ssh-add terminates.

But when unison is run from Mutt, this is worse, as ssh-add doesn't
terminate on receiving a key.

So it seems that ssh-add incorrectly handles signals.

Note that if I run ssh-add with several files directly from the
shell, there are no issues: ssh-add is killed as expected, without
printing anything about the other files.

[...]
> But a "kill -QUIT 2358" killed it:
[...]

However, the terminal got in a broken state and mutt was no longer
receiving any key.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


Reply to: