forked from aprey10/ssh-authorizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssh-authorizer.sh
executable file
·35 lines (32 loc) · 1.08 KB
/
ssh-authorizer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
HOST=
KEYS_LOCATION=~/.ssh/id_rsa.pub
while [[ ! $# -eq 0 ]]
do
case "$1" in
-help)
echo "-----------------------------------------------------------------------------------------------------------"
echo "Script which allows to skip entering password or passphrase when working with remote Linux host through SSH"
echo "-----------------------------------------------------------------------------------------------------------"
printf "\n"
echo "Available options:"
printf "\n"
echo "-host or -h: IP or hostname of remote machine with username, format: [email protected]"
echo "-kp: SSH keys location, default value: ~/.ssh/id_rsa.pub"
echo "-help: help"
printf "\n"
echo "Example: ./ssh-authorizer.sh -host vm1"
exit
;;
-host)
HOST=$2
;;
-h)
HOST=$2
;;
esac
shift
done
ssh-copy-id -i $KEYS_LOCATION $HOST
eval `ssh-agent`
ssh-add $KEYS_LOCATION