-
Notifications
You must be signed in to change notification settings - Fork 50
/
ssh.conf
36 lines (31 loc) · 968 Bytes
/
ssh.conf
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
# Appends a public key to .ssh/authorized_keys on the given server.
#
# Usage: ssh_key_upload <server> [key_file.pub]
#
# Defaults to ~/.ssh/id_rsa.pub if no key specified.
ssh_key_upload() {
local destination publicKey dotSsh authorizedKeys
destination="$1"
publicKey="${2:-$HOME/.ssh/id_rsa.pub}"
dotSsh=".ssh"
authorizedKeys=".ssh/authorized_keys"
cat "$publicKey" | ssh "${destination}" "mkdir -p \$HOME/${dotSsh}; chmod 700 \$HOME/${dotSsh}; \
cat >> \$HOME/${authorizedKeys}; chmod 600 \$HOME/${authorizedKeys}"
}
# Set up ssh agent
function init-agent () {
if ssh-add -l >/dev/null 2>&1; then
return 0
else
test -e ~/.agent.env && . ~/.agent.env > /dev/null
if ssh-add -l >/dev/null 2>&1; then
return 0
else
ssh-agent > ~/.agent.env 2>/dev/null
. ~/.agent.env >/dev/null 2>&1
ssh-add $HOME/.ssh/*_rsa >/dev/null 2>&1
return 0
fi
fi
}
init-agent