Add username spec
This commit is contained in:
parent
97ca243214
commit
0d7158795e
@ -9,7 +9,7 @@ The SSH Key must be stored in your lastpass account, as a Secure Note of the typ
|
||||
|
||||
## Usage
|
||||
1. Download the script to a location of your choosing, ensuring it is executable
|
||||
2. run it like this: ```./ssh.sh KEYNAME server-you-wish-to-ssh-to```
|
||||
2. run it like this: ```./ssh.sh KEYNAME USERNAME server-you-wish-to-ssh-to```
|
||||
|
||||
## How it works
|
||||
This script uses the official `lastpass-cli` package to pull the private key to a file and the private key passphrase to a variable. The script then uses that information to ssh to the requested server, and removes the private key when the connection is closed.
|
||||
@ -22,7 +22,7 @@ The SSH Key must be stored in your lastpass account, as a Secure Note of the typ
|
||||
|
||||
## Usage
|
||||
1. Download the script to a location of your choosing, ensuring it is executable
|
||||
2. run it like this: ```./ssh-copy-id.sh KEYNAME server-you-wish-to-ssh-to```
|
||||
2. run it like this: ```./ssh-copy-id.sh KEYNAME USERNAME server-you-wish-to-ssh-to```
|
||||
3. You will be prompted to answer if you would like to remove all old ssh keys currently installed on the remote host. This is strongly recommended.
|
||||
|
||||
## How it works
|
||||
|
@ -3,7 +3,8 @@
|
||||
|
||||
#Set variables
|
||||
keyname=${1}
|
||||
hostname=${2}
|
||||
username=${2}
|
||||
hostname=${3}
|
||||
keyfile=$HOME/.ssh/${keyname}-$(date "+%s")
|
||||
pubkeyfile=$HOME/.ssh/${keyname}-$(date "+%s").pub
|
||||
|
||||
@ -42,7 +43,7 @@ fi
|
||||
|
||||
#Add the key to ssh-agent
|
||||
echo "Copying id to $hostname, you may be asked to authenticate to SSH."
|
||||
ssh-copy-id -i $pubkeyfile $hostname
|
||||
ssh-copy-id -i $pubkeyfile $username@$hostname
|
||||
|
||||
#Remove keyfiles
|
||||
rm -f $keyfile
|
||||
|
6
ssh.sh
6
ssh.sh
@ -4,7 +4,9 @@
|
||||
#Set variables
|
||||
keyname=${1}
|
||||
|
||||
hostname=${2}
|
||||
username=${2}
|
||||
|
||||
hostname=${3}
|
||||
|
||||
keyfile=$HOME/.ssh/${keyname}-$(date "+%s")
|
||||
#Check to see if user is logged in to lastpass cli
|
||||
@ -34,7 +36,7 @@ expect << EOF
|
||||
EOF
|
||||
|
||||
#SSH to the host
|
||||
ssh $hostname
|
||||
ssh $username@$hostname
|
||||
|
||||
#Remove keyfile
|
||||
rm -f $keyfile
|
||||
|
Loading…
Reference in New Issue
Block a user