From 44c8da3f888763345fafd1ab6e269d129def237f Mon Sep 17 00:00:00 2001 From: Russ Long Date: Thu, 7 Feb 2019 14:06:12 -0500 Subject: [PATCH] Add key expiration to ssh-add --- ssh.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ssh.sh b/ssh.sh index 0c7fa62..8d9ef96 100755 --- a/ssh.sh +++ b/ssh.sh @@ -6,7 +6,7 @@ keyname=${1} hostname=${2} -keyfile=$HOME/.ssh/${keyname}_$(date "+%F-%T") +keyfile=$HOME/.ssh/${keyname}-$(date "+%s") #Check to see if user is logged in to lastpass cli #check_login() #{ @@ -27,7 +27,7 @@ sshpassphrase=$(lpass show $keyname --field=Passphrase) #Add the key to ssh-agent expect << EOF - spawn ssh-add $keyfile + spawn ssh-add -t 30 $keyfile expect "Enter passphrase" send "$sshpassphrase\r" expect eof @@ -36,8 +36,5 @@ EOF #SSH to the host ssh $hostname -#remove the key from the ssh-agent -ssh-add -d $keyfile - -#remove the key +#Remove keyfile rm -f $keyfile