Skip to content

Instantly share code, notes, and snippets.

@Darkflib
Last active September 4, 2018 05:01
Show Gist options
  • Select an option

  • Save Darkflib/aff2941f5f043043bd6753f245c79b3a to your computer and use it in GitHub Desktop.

Select an option

Save Darkflib/aff2941f5f043043bd6753f245c79b3a to your computer and use it in GitHub Desktop.
A small set of scripts for bringing up new hetzner images quickly... (The wireguard keys aren't valid anymore)
#!/bin/bash
apt update
apt -y upgrade
apt -y install cifs-utils vim sudo curl tmux apt-transport-https ca-certificates curl software-properties-common git git-crypt lolcat figlet cowsay screenfetch fail2ban git-lfs git-hub sshfs
echo "screenfetch" >> /root/.bash_profile
# docker key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# kube key
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
#no stable docker for 18.04 yet, need to use edge
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) edge"
#simialr issue with kubernetes, no bionic version yet :(
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get -y update
apt-get install -y docker-ce
#note: version may change from time to time
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
apt-get install -y kubelet kubeadm kubectl
#disable kubectl until we actually want it (it is noisy in the logs)
systemctl disable kubelet
docker run --rm hello-world
# docker and tools should be now installed
docker rmi hello-world
#!/bin/bash
echo "enter your smb username"
read smbuser
echo "enter your smb password"
read smbpass
mkdir -p /mnt/backup
apt update
apt -y install cifs-utils
echo "//${smbuser}.your-storagebox.de/backup /mnt/backup cifs username=${smbuser},password=${smbpass} 0 0" >> /etc/fstab
mount /mnt/backup
#!/bin/bash
echo "enter your sshfs username"
read smbuser
mkdir -p /mnt/backup
apt update
apt -y install sshfs
echo "sshfs#${smbuser}@${smbuser}.your-storagebox.de:/backup /mnt/backup fuse defaults,allow_other 0 0"
>> /etc/fstab
mount /mnt/backup
#!/bin/bash
# hetzner supports private vlans if you set them up in the control panel for physical servers
echo "enter your private ip"
read ip
ip link add link enp2s0 name enp2s0.4000 type vlan id 4000
ip link set enp2s0.4000 mtu 1400
ip link set dev enp2s0.4000 up
ip a add ${ip}/24 dev enp2s0.4000
[NetDev]
Name=wg0
Kind=wireguard
Description=Wireguard
# nbg09
[WireGuard]
PrivateKey = QJkFqbUitAAP8uP27LZzwJehMOAmww+5iDkc+71hjU0=
ListenPort = 56560
##### PEERS #####
# nbg03
[WireGuardPeer]
PublicKey = +Gn0/ApJsQMiu8xoBhaln3TtegvSxSXT1MpWy60xxjo=
AllowedIPs = 10.88.88.3/32
Endpoint = nbg03.example.net:56560
# nbg04
[WireGuardPeer]
PublicKey = 6g984PrxVutA/vJ5VRcJXJSJJ6Sb9jixc+QRmmgdlgY=
AllowedIPs = 10.88.88.4/32
Endpoint = nbg04.example.net:56560
# nbg05
[WireGuardPeer]
PublicKey = X13wTRAtro+81RbmQgwtMGqg6W4JmnCAEv+22vv3AFU=
AllowedIPs = 10.88.88.5/32
Endpoint = nbg05.example.net:56560
# nbg06
[WireGuardPeer]
PublicKey = nlUh1xq+I5HJp9eoYF7sLAlhK9zgL5g2+RZdTnXu6WU=
AllowedIPs = 10.88.88.6/32
Endpoint = nbg06.example.net:56560
# nbg07
[WireGuardPeer]
PublicKey = 7Bp7IqG3uicwkYNb+vZ1yQXHVoOcRIxKYgsv/UOl/kk=
AllowedIPs = 10.88.88.7/32
Endpoint = nbg07.example.net:56560
[Match]
Name=wg0
[Address]
Address=10.88.88.9/24
#!/bin/bash
# Hopefully this will be in kernel soon enough...
add-apt-repository ppa:wireguard/wireguard
apt-get install wireguard
mkdir -p /etc/wireguard/
cd /etc/wireguard/
wg genkey | tee privatekey | wg pubkey > publickey
@Darkflib

Darkflib commented Sep 4, 2018

Copy link
Copy Markdown
Author

systemctl restart systemd-networkd.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment