Skip to content

ssh-agent not getting cleaned on unclean exit #23

Closed
@MagikEh

Description

@MagikEh

Issue:

When you run a command that invokes the sr3_ssh script, it sets up a ssh-agent but that agent's socket is not cleaned up if the script unexpectedly exits. This leads to an absolute metric truckload of $TMPDIR/ssh-* dirs being created on the host.

Steps to reproduce

ls -dl  $TMPDIR/ssh-*
> # nothing returned

sr3l 'echo blah'
> host1: blah
> host2: blah
> host3: blah

ls -dl  $TMPDIR/ssh-*
> # nothing returned because the agent was cleaned up properly


sr3l 'echo blah'
> host1: blah
^C  #<--- Force the run to stop before it completes.

ls -dl  $TMPDIR/ssh-*
drwx------ 2 user      user      26 Feb  6 19:58 /tmp/ssh-XXXXXX2j1w9S/

Suggested Fix:

Add a trap to the bash script for on-exit signals:

trap 'ssh-agent -k' EXIT

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions