Browse Source

organized the linux cheatsheet

main
Ken Schaefer 2 years ago
parent
commit
6f75d0e9d7
  1. 9
      Cheatsheets/linux.md
  2. 159
      Runbooks/linux.md

9
Cheatsheets/linux.md

@ -0,0 +1,9 @@
## Networking
### Network information
```
ifconfig -a
```

159
Runbooks/linux.md

@ -3,56 +3,49 @@
## Install distro ## Install distro
## Post install ## Post install
```
apt update
apt upgrade
```
## Automatic Updates
To do updates manually. Don't do this on Production servers because you should have better planning to upgrade you key servers.
### Update && Upgrade
``` ```
apt update apt update
apt upgrade apt upgrade
``` ```
Install a utility that will perform auto-upgrades ### Automatic Updates
``` ```
apt install unattended-upgrades apt install unattended-upgrades
```
Configure the utility
```
dpkg-reconfigure --priority=low unattended-upgrades dpkg-reconfigure --priority=low unattended-upgrades
``` ```
## Create new sudo account ### Static IP
```
sudo adduser {username}
sudo usermod -aG sudo {username}
``` ```
sudo nano /etc/netplan/01-netcfg.yaml
## Disable root network:
version: 2
renderer: networkd
ethernets:
ens18:
dhcp4: no
addresses:
- 192.168.5.50/24
routes:
-to: default
via: 192.168.5.99
nameservers:
addresses: [192.168.5.25]
sudo netplan apply
``` ```
sudo passwd -l root
```
## SSH Logins
### Install openssh ### Install openssh
You can select this during Ubuntu install
``` ```
sudo apt install openssh-server sudo apt install openssh-server
```
### Setup key generated login
```
ssh-keygen ssh-keygen
``` ```
Go to LINUX client machine ### SSH on Client machine
LINUX client machine
``` ```
ssh-keygen ssh-keygen
ssh-copy-id username@ipaddress ssh-copy-id username@ipaddress
@ -63,47 +56,21 @@ ssh-keygen
Get-Content $env:USERPROFILE\.ssh\id_rsa.pub | ssh <user>@<hostname> "cat >> .ssh/authorized_keys" Get-Content $env:USERPROFILE\.ssh\id_rsa.pub | ssh <user>@<hostname> "cat >> .ssh/authorized_keys"
``` ```
### Lockdown Logins ### Lockdown Logins to SSH only
Edit the following file in nano on the server:
``` ```
sudo nano /etc/ssh/sshd_config sudo nano /etc/ssh/sshd_config
``` ```
Make the following changes: Make the following changes:
1. Change PasswordAuthentication to **no** 1. Change PasswordAuthentication to **no**
2. Change ChallengeResponseAuthentication to **no** 2. Change ChallengeResponseAuthentication to **no**
Save the file and restart the ssh service Save the file and restart the ssh service
``` ```
sudo systemctl restart sshd sudo systemctl restart sshd
``` ```
## Static IP ### Fix LVM
```
sudo nano /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
ens18:
dhcp4: no
addresses:
- 192.168.5.50/24
routes:
-to: default
via: 192.168.5.99
nameservers:
addresses: [192.168.5.25]
sudo netplan apply
```
## Fix LVM
``` ```
sudo lvm sudo lvm
lvm > lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv lvm > lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
@ -112,35 +79,14 @@ exit
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
``` ```
## Change HOSTNAME ### Change timezone
```
sudo hostnamectl set-hostname {hostname}
hostnamectl
sudo nano /etc/hosts
/* change hostname in hosts file */
```
## Change timezone
``` ```
timedatectl timedatectl
timedatectl list-timezones timedatectl list-timezones
sudo timedatectl set-timezone America/Chicago sudo timedatectl set-timezone America/Chicago
``` ```
## Install Guest Agent for Proxmox ### Configure Firewall
Applies only if this box is in a Proxmox server
1. Open Proxmox
2. Click Options
3. Turn on QEMU Agent
```
sudo apt install qemu-guest-agent
sudo shutdown
```
## Configure Firewall
``` ```
sudo ufw status sudo ufw status
sudo ufw default allow outgoing sudo ufw default allow outgoing
@ -148,7 +94,8 @@ sudo ufw default deny incoming
sudo ufw allow ssh sudo ufw allow ssh
sudo ufw enable sudo ufw enable
``` ```
## Install fail2ban
### Install fail2ban
``` ```
sudo apt install fail2ban sudo apt install fail2ban
sudo cp /etc/fail2ban/fail2ban.{conf,local} sudo cp /etc/fail2ban/fail2ban.{conf,local}
@ -170,4 +117,54 @@ sudo systemctl restart fail2ban
sudo fail2ban-client status /* use to review banned */ sudo fail2ban-client status /* use to review banned */
``` ```
## Logging with Prometheus ## Optional Maintenance
### Create new sudo account
Ubuntu Server does this by default
```
sudo adduser {username}
sudo usermod -aG sudo {username}
```
### Disable root
Ubuntu Server does this by default
```
sudo passwd -l root
```
### Change HOSTNAME
```
sudo hostnamectl set-hostname {hostname}
hostnamectl
sudo nano /etc/hosts
/* change hostname in hosts file */
```
## Optional Services
### Install xRDP
If you need to use RDP to access a desktop environment
```
sudo apt install xrdp
sudo systemctl enable xrdp
```
### Install GIT
```
sudo apt install git
```
### Install Guest Agent for Proxmox
Applies only if this box is in a Proxmox server
1. Open Proxmox
2. Click Options
3. Turn on QEMU Agent
```
sudo apt install qemu-guest-agent
sudo shutdown
```
### Logging with Prometheus
Loading…
Cancel
Save