Update ssh key generation to generate keys for all hosts

main
Ensar Sarajčić 2022-07-08 13:29:52 +02:00
parent 8db3cebb14
commit 4e413f26f9
3 changed files with 30 additions and 17 deletions

View File

@ -52,7 +52,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Run key creation
run: echo "test\n\n" | make create_personal_ssh_github_key
run: echo "test\n\n\n\n\n\n\n\n" | make create_personal_ssh_keys
env:
DOTFILES_CI: 1
stylua:

View File

@ -80,6 +80,23 @@ define write_git_ssh_config_entry
@echo " IdentityFile $3" >> $(SSH_CONFIG_FILE)
endef
# Creates a new ssh key and saves it to config
# Takes 3 parameters:
# - Email
# - Host name (ex. codeberg)
# - Host (ex. codeberg.org)
define create_personal_git_ssh_key
ssh-keygen -f $(PERSONAL_SSH_KEYS_HOME)/id_ed25519_$2 -t ed25519 -b 4096 -C $1
@echo "Personal $2 key created!"
@echo "Copy public key by running:"
@echo ""
@echo "cat $(PERSONAL_SSH_KEYS_HOME)/id_ed25519_$2.pub | $(COPY_TOOL)"
@echo ""
@echo "Open SSH page on $3"
@echo "and paste copied public key"
$(call write_git_ssh_config_entry,$3,,$(PERSONAL_SSH_KEYS_HOME)/id_ed25519_$2)
endef
.PHONY: bootstrap
bootstrap: check_os
@echo "Bootstrapped everything!"
@ -215,26 +232,22 @@ prepare_scripts_cache_dir: check_os
.PHONY: clone_personal_vimwiki
clone_personal_vimwiki: check_os
@echo "Cloning personal vimwiki"
@git clone git@github.com:esensar/vimwiki.wiki.git ~/vimwiki
@git clone git@ensarsarajcic.com:esensar/vimwiki.wiki.git ~/vimwiki
.PHONY: prepare_ssh_dir
prepare_ssh_dir: check_os
@echo "Creating ssh directories"
@mkdir -p $(HOME)/.ssh/Personal
.PHONY: create_personal_ssh_github_key
create_personal_ssh_github_key: check_os prepare_ssh_dir
@echo "Creating personal GitHub key"
@read -p "Enter your email: " email; \
ssh-keygen -f $(PERSONAL_SSH_KEYS_HOME)/id_rsa_github -t rsa -b 4096 -C $$email
@echo "Personal GitHub key created!"
@echo "Copy public key by running:"
@echo ""
@echo "cat $(PERSONAL_SSH_KEYS_HOME)/id_rsa_github.pub | $(COPY_TOOL)"
@echo ""
@echo "Open: https://github.com/settings/ssh/new"
@echo "and paste copied public key"
$(call write_git_ssh_config_entry,github.com,,$(PERSONAL_SSH_KEYS_HOME)/id_rsa_github)
.PHONY: create_personal_ssh_keys
.ONESHELL:
create_personal_ssh_keys: check_os prepare_ssh_dir
@echo "Creating personal ssh keys"
@read -p "Enter your email: " email;
$(call create_personal_git_ssh_key,$$email,personal_git,git.ensarsarajcic.com);
$(call create_personal_git_ssh_key,$$email,codeberg,codeberg.org);
$(call create_personal_git_ssh_key,$$email,sourcehut,git.sr.ht);
$(call create_personal_git_ssh_key,$$email,github,github.com);
.PHONY: prepare_fish_shell
prepare_fish_shell: check_os

View File

@ -46,9 +46,9 @@ make bootstrap
After installation optionally check out `installed_packages` directory for packages to install using `clone-installation`.
This repository also provides a simple way to generate main personal ssh key to be used with GitHub:
This repository also provides a simple way to generate personal ssh keys to be used with used git hosts:
```
make create_personal_ssh_github_key
make create_personal_ssh_keys
```
It is recommended to also clone `vimwiki` and use it (this is a private repository and applies only to owner):