Add key expiration to ssh-add
This commit is contained in:
parent
a29c8b5d67
commit
44c8da3f88
9
ssh.sh
9
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
|
||||
|
Loading…
Reference in New Issue
Block a user