dotfiles/ssh/makefile

36 lines
957 B
Makefile

SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
CONFIG_SRC := $(SRC_DIR)/config
CONFIG_TRGT := ~/.ssh/config
JPATRICK_KEY := ~/.ssh/git.jpatrick.io
include ../lib/shared.mk
install: | init update
init:
$(info => Setting up ssh)
$(mk_link) $(CONFIG_SRC) $(CONFIG_TRGT)
$(mk_link) $(SRC_DIR)/public_keys ~/.ssh/public_keys
$(MAKE) -C $(SRC_DIR) init_jpatrick_key
update:
cd ~/.ssh \
&& mkdir -p public_keys/`hostname` \
&& for i in *.pub ; do ; \
cp $$i public_keys/`hostname`/$$i ; \
done
remove:
$(info => Remvoing ssh)
$(rm_link) $(TARGET)
$(report) warn "NOTE: All prior keys still remain."
init_jpatrick_key:
ifeq ($(shell [ ! -e $(JPATRICK_KEY) ] $(return_val_truthy) ), true)
$(report) info "Setting up key for jpatrick.io"
ssh-keygen -t ed25519 -C "`hostname`: `date`" -f $(JPATRICK_KEY) -N "" \
; $(report) info "jpatrick.io key created"
else
$(report) warn "Key for jpatrick.io already created"
endif