ref(ssh-pubkey): prefer ~ over $HOME for unquoted paths

This commit is contained in:
AJ ONeal
2024-05-16 19:46:19 +00:00
parent fa71ef9002
commit 345d4fa146

View File

@@ -4,29 +4,29 @@ set -u
main() {
if [ ! -d "$HOME/.ssh" ]; then
mkdir -p "$HOME/.ssh/"
chmod 0700 "$HOME/.ssh/"
if [ ! -d ~/.ssh ]; then
mkdir -p ~/.ssh/
chmod 0700 ~/.ssh/
fi
if [ ! -f "$HOME/.ssh/config" ]; then
if [ ! -f ~/.ssh/config ]; then
# for the benefit of VSCode
touch "$HOME/.ssh/config"
chmod 0644 "$HOME/.ssh/config"
touch ~/.ssh/config
chmod 0644 ~/.ssh/config
fi
if [ ! -f "$HOME/.ssh/authorized_keys" ]; then
touch "$HOME/.ssh/authorized_keys"
chmod 0600 "$HOME/.ssh/authorized_keys"
if [ ! -f ~/.ssh/authorized_keys ]; then
touch ~/.ssh/authorized_keys
chmod 0600 ~/.ssh/authorized_keys
fi
if [ ! -f "$HOME/.ssh/id_rsa" ]; then
ssh-keygen -b 2048 -t rsa -f "$HOME/.ssh/id_rsa" -q -N ""
if [ ! -f ~/.ssh/id_rsa ]; then
ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N ""
echo >&2 ""
fi
if [ ! -f "$HOME/.ssh/id_rsa.pub" ]; then
ssh-keygen -y -f "$HOME/.ssh/id_rsa" > "$HOME/.ssh/id_rsa.pub"
if [ ! -f ~/.ssh/id_rsa.pub ]; then
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
echo >&2 ""
fi