summaryrefslogtreecommitdiff
path: root/add-ssh-keys.sh
blob: a18824441a4c8fe5a87b7987e563a6d99a7c7c09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

cd "$script_dir" || exit 1

mkdir -p ~/.ssh

touch ~/.ssh/authorized_keys

for pubkey in *.pub; do
    if [[ -f "$pubkey" ]]; then
        cat "$pubkey" >> ~/.ssh/authorized_keys
        echo "Added $pubkey to authorized_keys"
    fi
done

chmod 600 ~/.ssh/authorized_keys

  # removes duplicates
#sort -u ~/.ssh/authorized_keys -o ~/.ssh/authorized_keys