Document Host Setup and Security Standards #86
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Write a document describing how hosts are secured as part of a standard deployment of a new host.
It is also probably a good idea to identify weaknesses or other shortcomings in the current model.
assigned to @Jafner
changed the description
changed title from Document Host Security Standards to Document Host {+Setup and +}Security Standards
Create Admin User
sudo
,su -
, or by logging in as the root user.adduser admin
to create the non-root admin user.usermod -aG sudo admin
to add the new user to the sudo group.sudo visudo
and append this line to the end of the file:admin ALL=(ALL) NOPASSWD:ALL
to enable passwordless sudo.After these, you can
sudo su admin
to log into the new user account.https://www.cyberciti.biz/faq/add-new-user-account-with-admin-access-on-linux/
https://www.cyberciti.biz/faq/linux-unix-running-sudo-command-without-a-password/
Configure Secure SSH
mkdir -p /home/admin/.ssh && echo "<insert pubkey here>" >> /home/admin/.ssh/authorized_keys
Add pubkey to authorized_keys. Make sure to place the correct SSH pubkey in the command before copying.sudo apt install libpam-google-authenticator
to install the Google 2FA PAM.google-authenticator
to configure the 2FA module. Use the following responses when prompted:y
y
y
n
(refers to increasing time skew window)y
We enter our TOTP secret key into our second authentication method and save our one-time backup recovery codes.sudo nano /etc/pam.d/sshd
to edit the PAM configuration, and add this line to the top of the fileauth sufficient pam_google_authenticator.so nullok
5a.
sudo nano /etc/ssh/sshd_config
to open the SSH daemon config for editing. Make sure the following assertions exist:PubkeyAuthentication yes
AuthenticationMethods publickey,keyboard-interactive
PasswordAuthentication no
ChallengeResponseAuthentication yes
UsePAM yes
5b.
echo $'PubkeyAuthentication yes\nAuthenticationMethods publickey,keyboard-interactive\nPasswordAuthentication no\nChallengeResponseAuthentication yes\nUsePAM yes' | sudo tee /etc/ssh/sshd_config.d/ssh.conf
to perform the above as a one-liner. Requires a version of OpenSSH/Linux that supports sourcing sshd config from the/etc/ssh/sshd_config.d/*.conf
path.sudo systemctl restart sshd.service
to restart the SSH daemon.changed the description
Install Basic Packages
sudo apt install curl nano inxi git htop
Install Docker
curl -fsSL https://get.docker.com | sudo sh
This is the most convenient and least safe way to do this. If this script is ever compromised, we'd be fucked.sudo systemctl enable docker
to enable the Docker service.sudo usermod -aG docker $USER
to add the current user (should be non-root admin) to docker group.logout
to relog and apply the new permissions.mentioned in issue #92
Clone the homelab repo
warlock
and have the following scopes:read_api
,read_user
,read_repository
.mkdir ~/homelab ~/data && cd ~/homelab/ && git init && git config core.sparseCheckout true && git config pull.ff only
to init the repository with sparse checkout enabled.git remote add -f origin https://<pat-name>:<pat-value>@gitlab.jafner.net/Jafner/homelab.git
to add the repo with authentication via read-only personal access token. NOTE: Make sure to replace<pat-name>
with the name of the personal access token, and replace<pat-value>
with the key for the personal access token.echo "$HOSTNAME/" > .git/info/sparse-checkout
to configure sparse checkout for the host.git checkout main
to switch to the main branch with the latest files.Set the Hostname
sudo hostnamectl set-hostname <hostname>
to set the hostname.sudo nano /etc/hosts
and edit the old value for127.0.1.1
to use the new hostname.Current map of IPs to old and new hostnames:
router
wizard
joey-nas
barbarian
truenas
monk
joey-server
orjafner.net
fighter
joey-seedbox
orjafner.chat
warlock
WYSE-B8H3JV2
paladin
WYSE-B8D2JV2
ranger
WYSE-B8N8JV2
cleric
jafner.tools
druid
Update VyOS
add system image <link to build image>
Note: If you do not want the most recent image to be used by default, you can use the command
set system image default-boot <image>
You can view available system images with
show system image
, which will include telling you which is currently the default boot image.You can delete old system images with
delete system image <image>
Set up SSH 2FA on VyOS
generate system login username vyos otp-key hotp-time rate-limit 3 rate-time 30 window-size 3
to generate the key and print out the commands to add it to the given user.set system login user vyos authentication otp key <key>
to configure the new key for the user.Set Host Name in VyOS
configure; set system host-name <hostname>; commit; save; exit
mentioned in commit
7c0bcdd546
Closing. Further work will go under #110 and #111