From eac4231c1ef15fb27f070a834933996ba63c305e Mon Sep 17 00:00:00 2001 From: ray Date: Fri, 4 Sep 2020 21:19:35 +0100 Subject: [PATCH] use git over ssh --- README.md | 3 --- files/id_rsa.pub | 1 + files/known_hosts | 2 ++ scripts/debian10/install-dev-base.sh | 4 ++-- scripts/debian10/install-user.sh | 27 ++++++++++++++++++--------- 5 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 files/id_rsa.pub create mode 100644 files/known_hosts diff --git a/README.md b/README.md index 94842d8..aaf3f62 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,3 @@ Development environment base packages: * lf * lazygit -## TODO - -* add ssh keys to user so can use git - how to do securely?? diff --git a/files/id_rsa.pub b/files/id_rsa.pub new file mode 100644 index 0000000..e16bf66 --- /dev/null +++ b/files/id_rsa.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDEwwL1J52P0IuAWa+Ar3tCFOmT3A+V4F6/nz3JwGozCGaPrIqyOW7R3R+Y9UZZrxHYT7pt71lhNDQdN4Elhiix6Zkzrf4ZJRDfcyGvg7ZQGOG2nODybmW0TilnELtfjmtiaJ/2wBxNCiwdZAzFCb0kNKyXsUqx3b4NA7nKoxlVEdK1SZyaqwpe4oO6eoj6Nl2fPpLJ7Xq7VX83UJJPofPs3qUYOB2ywhKMljjbHDbQrRr+7Z3vQwmSs8sGI6qh1OHR7HZ2x8kVK507uwKXKPBlLGVKT2RDTslQiooNuuInBD/+DDegme+2arfnHIKB+GWK4Sun6aeN8UcMqA03GsRj dev-scripts@dev diff --git a/files/known_hosts b/files/known_hosts new file mode 100644 index 0000000..afabf0f --- /dev/null +++ b/files/known_hosts @@ -0,0 +1,2 @@ +|1|3oVXnt29xONh6+jmV3anxv2jUlE=|6FMJKCQKcgMN0RKsZPt4QcX/Dcw= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEon87+GR5+/I0SwUrsf7TlKQFXkgyYxqnHC4YyZ2i9LbuCrGi3hPibV1tZL4FTyqrI87+uxnZRDznXY2lpLP8Y= +|1|3oVXnt29xONh6+jmV3anxv2jUlE=|6FMJKCQKcgMN0RKsZPt4QcX/Dcw= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEon87+GR5+/I0SwUrsf7TlKQFXkgyYxqnHC4YyZ2i9LbuCrGi3hPibV1tZL4FTyqrI87+uxnZRDznXY2lpLP8Y= diff --git a/scripts/debian10/install-dev-base.sh b/scripts/debian10/install-dev-base.sh index 0b8ac24..a973a30 100755 --- a/scripts/debian10/install-dev-base.sh +++ b/scripts/debian10/install-dev-base.sh @@ -53,7 +53,7 @@ npm install -g neovim python2 -m pip install --user --upgrade pynvim python3 -m pip install --user --upgrade pynvim python3 -m pip install --user --upgrade neovim-remote -git clone https://git.rayelliott.dev/dots/nvim.git $_home_dir/.config/nvim +git clone ssh://git@git.rayelliott.dev:3222/dots/nvim.git $_home_dir/.config/nvim curl -fLo $_home_dir/.config/nvim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim nvim --headless +PlugInstall +qall @@ -65,7 +65,7 @@ lf config if [ -e "$_home_dir/.config/lf" ] ; then mv "$_home_dir/.config/lf" "$_home_dir/.config/lf-original-$(date +%s)" fi -git clone https://git.rayelliott.dev/dots/lf.git "$_home_dir/.config/lf" +git clone ssh://git@git.rayelliott.dev:3222/dots/lf.git "$_home_dir/.config/lf" EOSSH diff --git a/scripts/debian10/install-user.sh b/scripts/debian10/install-user.sh index 7ab1dbf..f5fa0f9 100755 --- a/scripts/debian10/install-user.sh +++ b/scripts/debian10/install-user.sh @@ -2,9 +2,20 @@ _home_dir="/home/$user" -echo "Adding user: $user" +echo "Configuring ssh keys .." + +ssh $ssh mkdir -p "$_home_dir/.ssh" +scp files/private/id_rsa "$ssh:$_home_dir/.ssh/" +scp files/id_rsa.pub "$ssh:$_home_dir/.ssh/" +scp files/known_hosts "$ssh:$_home_dir/.ssh/" ssh -T $ssh << EOSSH + cp /root/.ssh/authorized_keys "$_home_dir/.ssh/authorized_keys" + chown -R "$user:$group" "$_home_dir/.ssh" + # add git.rayelliott.dev to known hosts + + echo "Adding user: $user" + if [ -f /etc/locale.gen ] && command -v locale-gen ; then echo 'en_GB.UTF-8 UTF-8' > /etc/locale.gen locale-gen @@ -22,30 +33,28 @@ ssh -T $ssh << EOSSH echo "$user:$user_pass" | chpasswd usermod -aG sudo "$user" - mkdir -p "$_home_dir/.ssh" - cp /root/.ssh/authorized_keys "$_home_dir/.ssh/authorized_keys" - chown -R "$user:$group" "$_home_dir/.ssh" - echo "Cloning configuration files .." - su "$user" + su --login "$user" + git config --global user.name rayelliott + git config --global user.email dev@rayelliott.dev mkdir -p "$_home_dir/.config" if [ -e "$_home_dir/.config/profile" ] ; then mv "$_home_dir/.config/profile" "$_home_dir/.config/profile-original-$(date +%s)" fi - git clone https://git.rayelliott.dev/dots/profile.git "$_home_dir/.config/profile" + git clone ssh://git@git.rayelliott.dev:3222/dots/profile.git "$_home_dir/.config/profile" "$_home_dir/.config/profile/install.sh" if [ -e "$_home_dir/.config/tmux" ] ; then mv "$_home_dir/.config/tmux" "$_home_dir/.config/tmux-original-$(date +%s)" fi - git clone https://git.rayelliott.dev/dots/tmux.git "$_home_dir/.config/tmux" + git clone ssh://git@git.rayelliott.dev:3222/dots/tmux.git "$_home_dir/.config/tmux" "$_home_dir/.config/tmux/install.sh" if [ -e "$_home_dir/.config/zsh" ] ; then mv "$_home_dir/.config/zsh" "$_home_dir/.config/zsh-original-$(date +%s)" fi - git clone https://git.rayelliott.dev/dots/zsh.git "$_home_dir/.config/zsh" + git clone ssh://git@git.rayelliott.dev:3222/dots/zsh.git "$_home_dir/.config/zsh" "$_home_dir/.config/zsh/install.sh" EOSSH