Allow for spacing
This commit is contained in:
parent
0d7158795e
commit
2f2e38c143
@ -2,11 +2,12 @@
|
||||
#Maintained by Linux Operations - Russ Long - <rlong@nabancard.com>
|
||||
|
||||
#Set variables
|
||||
keyname=${1}
|
||||
keyname="${1}"
|
||||
username=${2}
|
||||
hostname=${3}
|
||||
keyfile=$HOME/.ssh/${keyname}-$(date "+%s")
|
||||
pubkeyfile=$HOME/.ssh/${keyname}-$(date "+%s").pub
|
||||
keysavename=$(echo -e ${keyname} | tr -d '[:space:]' | awk -F"/" '{print $NF}')
|
||||
keyfile=$HOME/.ssh/${keysavename}-$(date "+%s")
|
||||
pubkeyfile=$HOME/.ssh/${keysavename}-$(date "+%s").pub
|
||||
|
||||
#Check to see if user is logged in to lastpass cli
|
||||
if lpass status | grep -q "Logged in as"; then
|
||||
@ -16,12 +17,12 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Fetch private key and place in /home/$user/.ssh/$keyname-datetime
|
||||
lpass show $keyname --field="Private Key" > $keyfile
|
||||
#Fetch private key and place in /home/$user/.ssh/$keysavename-datetime
|
||||
lpass show "$keyname" --field="Private Key" > $keyfile
|
||||
chmod 0600 $keyfile
|
||||
|
||||
#Fetch public Key and place in /home/$user/.ssh/$keyname-datetime.pub
|
||||
lpass show $keyname --field="Public Key" > $pubkeyfile
|
||||
#Fetch public Key and place in /home/$user/.ssh/$keysavename-datetime.pub
|
||||
lpass show "$keyname" --field="Public Key" > $pubkeyfile
|
||||
|
||||
#Ask user if they wish to remove old keys
|
||||
read -r -p "Do you wish to remove ALL other ssh keys for your user on $hostname? [Y/n]" removeresponse
|
||||
|
12
ssh.sh
12
ssh.sh
@ -2,13 +2,15 @@
|
||||
#Maintained by Linux Operations - Russ Long - <rlong@nabancard.com>
|
||||
|
||||
#Set variables
|
||||
keyname=${1}
|
||||
keyname="${1}"
|
||||
|
||||
username=${2}
|
||||
|
||||
hostname=${3}
|
||||
|
||||
keyfile=$HOME/.ssh/${keyname}-$(date "+%s")
|
||||
keysavename=$(echo -e ${keyname} | tr -d '[:space:]' | awk -F"/" '{print $NF}')
|
||||
|
||||
keyfile=$HOME/.ssh/${keysavename}-$(date "+%s")
|
||||
#Check to see if user is logged in to lastpass cli
|
||||
#check_login()
|
||||
#{
|
||||
@ -20,12 +22,12 @@ keyfile=$HOME/.ssh/${keyname}-$(date "+%s")
|
||||
fi
|
||||
#}
|
||||
|
||||
#Fetch private key and place in /home/$user/.ssh/$keyname_datetime
|
||||
lpass show $keyname --field="Private Key" > $keyfile
|
||||
#Fetch private key and place in /home/$user/.ssh/$keysavename_datetime
|
||||
lpass show "$keyname" --field="Private Key" > $keyfile
|
||||
chmod 0600 $keyfile
|
||||
|
||||
#store passphrase in a variable
|
||||
sshpassphrase=$(lpass show $keyname --field=Passphrase)
|
||||
sshpassphrase=$(lpass show "$keyname" --field=Passphrase)
|
||||
|
||||
#Add the key to ssh-agent
|
||||
expect << EOF
|
||||
|
Loading…
Reference in New Issue
Block a user