summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/ssh5
-rw-r--r--bin/ssh-add-helper13
2 files changed, 17 insertions, 1 deletions
diff --git a/bin/ssh b/bin/ssh
index 525c9a0..91e79b7 100644
--- a/bin/ssh
+++ b/bin/ssh
@@ -2,6 +2,9 @@
SSH=/usr/bin/$(basename $0)
-keychain -q --timeout 30 ~/.ssh/id_dsa
+keychain -q --timeout 30
. ~/.keychain/${HOSTNAME}-sh
+if ! ssh-add -l | grep -q '.ssh/id_dsa'; then
+ ssh-add-helper ~/.ssh/id_dsa
+fi
$SSH $*
diff --git a/bin/ssh-add-helper b/bin/ssh-add-helper
new file mode 100644
index 0000000..605a702
--- /dev/null
+++ b/bin/ssh-add-helper
@@ -0,0 +1,13 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use IO::Pty::Easy;
+
+my $pass = `pwsafe -pE ssh.magus`;
+my $pty = IO::Pty::Easy->new;
+$pty->spawn("ssh-add $ARGV[0]");
+$pty->read;
+$pty->write($pass . "\n");
+while (1) {
+ last if $pty->read =~ 'Identity added';
+}