wrap with block
[webi-installers/.git] / ssh-utils / ssh-pubkey.sh
1 #!/bin/bash
2
3 {
4     set -e
5     set -u
6
7     mkdir -p "$HOME/.ssh/"
8
9     if [ ! -f "$HOME/.ssh/id_rsa" ]; then
10         ssh-keygen -b 2048 -t rsa -f "$HOME/.ssh/id_rsa" -q -N ""
11         echo ""
12     fi
13
14     if [ ! -f "$HOME/.ssh/id_rsa.pub" ]; then
15         ssh-keygen -y -f "$HOME/.ssh/id_rsa" > "$HOME/.ssh/id_rsa.pub"
16         echo ""
17     fi
18
19     # TODO use the comment (if any) for the name of the file
20     echo ""
21     echo "~/Downloads/id_rsa.$(whoami).pub":
22     echo ""
23     rm -f "$HOME/Downloads/id_rsa.$(whoami).pub":
24     cp -r "$HOME/.ssh/id_rsa.pub" "$HOME/Downloads/id_rsa.$(whoami).pub"
25     cat "$HOME/Downloads/id_rsa.$(whoami).pub"
26     echo ""
27 }