X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=ssh-utils%2Fssh-pubkey.sh;h=ed5c345aaa91b472414338ea12ecd1d482b15308;hb=684bdf6ff8a0d438a774429ccd88dbe02f5b79e3;hp=9f0722911b6ee68640012814bf885f2b60aa580b;hpb=2d4cc2a75db4fcaec63afa48a3fec3be3a0732b8;p=webi-installers%2F.git diff --git a/ssh-utils/ssh-pubkey.sh b/ssh-utils/ssh-pubkey.sh index 9f07229..ed5c345 100644 --- a/ssh-utils/ssh-pubkey.sh +++ b/ssh-utils/ssh-pubkey.sh @@ -4,24 +4,38 @@ set -e set -u - mkdir -p "$HOME/.ssh/" + if [ ! -d "$HOME/.ssh" ]; then + mkdir -p "$HOME/.ssh/" + chmod 0700 "$HOME/.ssh/" + fi + + if [ ! -f "$HOME/.ssh/config" ]; then + # for the benefit of VSCode + touch "$HOME/.ssh/config" + chmod 0644 "$HOME/.ssh/config" + fi + + if [ ! -f "$HOME/.ssh/authorized_keys" ]; then + touch "$HOME/.ssh/authorized_keys" + chmod 0600 "$HOME/.ssh/authorized_keys" + fi if [ ! -f "$HOME/.ssh/id_rsa" ]; then ssh-keygen -b 2048 -t rsa -f "$HOME/.ssh/id_rsa" -q -N "" - echo "" + >&2 echo "" fi if [ ! -f "$HOME/.ssh/id_rsa.pub" ]; then ssh-keygen -y -f "$HOME/.ssh/id_rsa" > "$HOME/.ssh/id_rsa.pub" - echo "" + >&2 echo "" fi # TODO use the comment (if any) for the name of the file - echo "" - echo "~/Downloads/id_rsa.$(whoami).pub": - echo "" - rm -f "$HOME/Downloads/id_rsa.$(whoami).pub": + >&2 echo "" + >&2 echo "~/Downloads/id_rsa.$(whoami).pub": + >&2 echo "" + rm -f "$HOME/Downloads/id_rsa.$(whoami).pub" cp -r "$HOME/.ssh/id_rsa.pub" "$HOME/Downloads/id_rsa.$(whoami).pub" cat "$HOME/Downloads/id_rsa.$(whoami).pub" - echo "" + >&2 echo "" }