refactor: properly setup ssh

This commit is contained in:
Strix 2023-10-29 17:24:17 +01:00
parent 9e69924211
commit 8e84f59ef5
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774
6 changed files with 58 additions and 19 deletions

21
doc/config/ssh_config Normal file
View file

@ -0,0 +1,21 @@
#####################
## IXVD ssh config ##
#####################
# This config describes what the bastion hose is and how to jump
Host link
HostName link.ixvd.net
Host keymaker
ProxyJump link
Host apoc
ProxyJump link
Host kid
ProxyJump link
Host mouse
ProxyJump link

View file

@ -2,20 +2,19 @@
## IXVD ssh config ##
#####################
# This config describes what the bastion hose is and how to jump
# This config describes where to connect to; internally.
Host link
HostName link.ixvd.net
HostName 10.0.0.2
Host keymaker
ProxyJump link
HostName 10.0.0.3
Host apoc
ProxyJump link
HostName 10.0.0.4
Host kid
ProxyJump link
HostName 10.0.0.5
Host mouse
ProxyJump link
HostName 10.0.0.6

View file

@ -0,0 +1,2 @@
# IXVD master key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDJQ/mhDJ3WhiUv9jtcfZcJBAGiThND8m3NUxH9DuuVEuK7dCDrK48afnfepw4qhAE9Q5FTxol1D2q7VXFpiOyjX2VIa6xqlKkQgoLuMWjp+CCWYHpj+8jUK/w8J3rWQQImNNkNKM93c5+EuhToJjrHI98pjGIPRceni7gWZ7GlWBmL/qnIvxMWhyZMSsupG36yqqMvYLdFOuOzSGgtaOqBb2v1JuTMTSVwXL8eZ36Je/J83sJmmVvvBq88xuS6tIf/dF+GuHZfJ3tbldWPlcS0kw2DvYorhiG3NWkiJ9QU7nDlXgsxjo2EkStb/uf8qkdGV8ZFYnEkJTQiS1MTyYYgx4g9E4QaDdjL1dWJOlNHsskZQ+ypz1cLV/QvrZOTkGct+KoraOVSAyNZCzI4TbLxM5vTre85bASO63DleKrHdO7MAESi+gEGIe+szbh52Tg8y5BNxE7Me9uKyjKaek44b65paC8GGeOyOvPH4QHO6YdFaQYu4h5V5qrfFNFbku8= ixvd master key

View file

@ -0,0 +1,10 @@
#!/bin/sh
if ! [ "$(id -u)" = "0" ]; then
echo "please perform as root, attempting to escalate privileges..."
exec sudo $(cat /proc/$$/cmdline | sed 's/\x00/ /g')
exit 1
fi
scp root@link.ixvd.net:/etc/ixvd/secrets/ssh/keys/master/ixvd-master /root/.ssh/id_rsa
chmod 600 /root/.ssh/id_rsa

View file

@ -0,0 +1,19 @@
#!/bin/bash
if ! cat -q "automation" /etc/passwd; then
echo "setting up automation user..."
useradd -m automation
mkdir -p /home/automation/.ssh
cat /etc/ixvd/secrets/ssh/keys/$HOSTNAME/id_rsa.pub > /home/automation/.ssh/authorized_keys
chown automation:automation /home/automation/.ssh/authorized_keys
cp /etc/ixvd/secrets/ssh/keys/$HOSTNAME/id_rsa /home/automation/.ssh/id_rsa
chown automation:automation /home/automation/.ssh/id_rsa
chmod 600 /home/automation/.ssh/id_rsa
cp /etc/ixvd/secrets/ssh/keys/$HOSTNAME/id_rsa.pub /home/automation/.ssh/id_rsa.pub
chown automation:automation /home/automation/.ssh/id_rsa.pub
chmod 600 /home/automation/.ssh/id_rsa.pub
fi

View file

@ -1,12 +0,0 @@
#!/bin/sh
if ! [ -f "/root/.ssh/authorized_keys" ]; then
echo "importing authorized_keys..."
mkdir -p /root/.ssh
cp /etc/ixvd/secrets/ssh/authorized_keys /root/.ssh/authorized_keys
else
if ! grep -q "# IXVD keys" /root/.ssh/authorized_keys; then
echo "importing authorized_keys..."
cat /etc/ixvd/secrets/ssh/authorized_keys >> /root/.ssh/authorized_keys
fi
fi