From b79f14b11a28eba106db2d76358ff79653d3aacd Mon Sep 17 00:00:00 2001 From: Yasmin Teles Date: Wed, 6 Mar 2024 14:08:46 -0300 Subject: [PATCH] feat: add ssh key script --- Makefile | 8 +++++++- install.sh | 20 ++++++++++++++------ ssh/config | 3 +++ 3 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 ssh/config diff --git a/Makefile b/Makefile index d88f0ee..e8d1339 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help del +.PHONY: help del ssh help: ## Show help. @printf "A set of development's commands.\n" @@ -9,4 +9,10 @@ help: ## Show help. del: ## delete your environment configuration @stow --dotfiles -D git + @stow -t ~/.ssh -D ssh @rm -rf ~/Projects + @rm -rf ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub + +ssh: ## Copy the SSH public key to your clipboard. + @pbcopy < ~/.ssh/id_ed25519.pub + @echo "Add the SSH public key to your account on GitHub or GiLlab. See your profile settings for more information." diff --git a/install.sh b/install.sh index 51ab6d7..b6f5252 100644 --- a/install.sh +++ b/install.sh @@ -2,18 +2,26 @@ read -p "What is your email? " GIT_EMAIL -print "\nPlease wait! It will configure your environment. \n" -echo "[1/3] Creating the Projects folder..." +printf "\nPlease wait! It will configure your environment.\n" +echo "[1/4] Creating the Projects folder..." mkdir ~/Projects -echo "[2/3] Setting up dotfiles..." +echo "[2/4] Setting up dotfiles..." git clone https://github.com/YasminTeles/dotfiles.git ~/.dotfiles cd ~/.dotfiles stow --dotfiles git +stow -t ~/.ssh ssh -echo "[3/3] Configuring Git..." +echo "[3/4] Configuring Git..." git config --global user.email $GIT_EMAIL -printf "\nSuccess Everythings is ready!" -printf "\nHave a nice day!" +echo "[4/4] Generating a new SSH key..." +rm -rf ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub +ssh-keygen -t ed25519 -C $GIT_EMAIL -f ~/.ssh/id_ed25519 -q -N "" +eval "$(ssh-agent -s)" +ssh-add ~/.ssh/id_ed25519 +echo "Warning: You must add the SSH public key to your account on GitHub or GitLab. For more information, see make ssh" + +printf "\nSuccess: Everything is ready!" +printf "\nHave a nice day!\n" diff --git a/ssh/config b/ssh/config new file mode 100644 index 0000000..081cd44 --- /dev/null +++ b/ssh/config @@ -0,0 +1,3 @@ +Host github.com + AddKeysToAgent yes + IdentityFile ~/.ssh/id_ed25519