- Create an hetzner server using Ubuntu
- Go to the Hetzner's Server dashboard > Images
- Click on "Mount" over the
alpine-linux-extended.isoimage - Shutdown the server
- Start the server
- Click the "Console" icon from the dashboard to open an interactive terminal session
- Login is
root - Configure the interface using the command
setup-interfaces - Pick to setup default
eth0 - Custom config:
no10 (bis). When asked if you want to include a custom configuration typeyes - Put this:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
dns-nameservers 213.133.100.100 213.133.98.98 213.133.99.99
# control-alias eth0
iface eth0 inet6 static
address <YOUR_IPV6_ADDRESS_FOUND_AT_THE_TOP_OF_THE_SERVER_DASHBOARD>
gateway fe80::1
-
Restart network service:
/etc/init.d/networking restart -
Check internet is available:
ping 8.8.8.8 -
Configure SSH:
setup-sshd -
Keep
opensshas default -
Create a user:
adduser Jhon -
Setup password
-
Temporarily soften ssh config to share ssh key:
vi /etc/ssh/sshd_config -
type
iin your keyboard to go in "insert mode" -
Find each of the following options and modify to look like this:
# TEMPORARILY Allow authentication with a password
PasswordAuthentication yes
- Once finished, type
ESC, then:wqto quit and save changes - Restart sshd
service sshd restart - On your laptop or somewhere else (not in the Hetzner server), generate an ssh-key:
ssh-keygen -t rsa -C "[email protected]" - Give a name to the ssh key, for example:
alpine_server_rsa(your choice) - Copy public key to alpine server:
ssh-copy-id -i ~/.ssh/alpine_server_rsa.pub -p 22 [email protected](WW.XX.YY.ZZ is the IPv4 of the Hetzner server) - Enter user's password to check it's you
- Now you should be connected from both your local laptop and the Hetzner console. Quit your local connection: type
exitthen Enter. - Go back to the still opened Hetzner console. We want to secure the SSH server before anything.
- Open SSH server config:
vi /etc/ssh/sshd_config - type
iin your keyboard to go in "insert mode" - Find each of the following options and modify to look like this:
# WOULD BE BETTER TO CHANGE DEFAULT 22 TO SOMETHING RANDOM
Port 7580
# Do not allow connection as "root"
PermitRootLogin prohibit-password
# Prevent retrying more than 6 times
MaxAuthTries 6
# Prevent authenticating with password: rsa file only
PasswordAuthentication no
# Do not allow empty/null passwords
PermitEmptyPasswords no
- Once finished, type
ESC, then:wqto quit and save changes - Restart sshd
service sshd restart - Now you can finally quit the Hetzner console: type
exitthen Enter. - From your local machine, now connect using ssh:
ssh -i ~/.ssh/alpine_server_rsa [email protected]
Hopefully you should be in, logged as the user John.
There may be some issues regarding the rsa key if shared to someone or used from another machine. Two options:
- In
/etc/ssh/sshd_configsetStrictModes no(dirty, not recommended) - Make sure that:
~/.ssh/authorized_keysin the remote server holds the proper PUBLIC rsa key.ls -l ~/.ssh/authorized_keysprints permissions to only your current user-rw-------orchmod 600 ~/.ssh/authorized_keys- Both your private and public keys (in your local machine) have only
-rw-------orchmod 600 ~/.ssh/*them. - Your
/homedirectory (in your local machine) have onlydrwx------orchmod 700 /home - Your
/home/.sshdirectory (in your local machine) have onlydrwx------orchmod 700 /home - Check your
/homedirectory owneship (in your local machine) matches with your remote/homedirectory ownership: like bothroot root. This one is usually tricky since people don't want to change ownership of their/hometo match a server config. So in that case do the opposite: change the location of the remote~/.ssh/authorized_keysto/etc/<WHATEVER>/authorized_keysthen don't forget to changeAuthorizedKeysFile /etc/<WHATEVER>/authorized_keysin/etc/ssh/sshd_configandservice sshd restart.
Install Docker + Git + Curl:
- Switch user to root:
su root - Enter password
- Add apk repos to
/etc/apk/repositories:
echo "http://dl-cdn.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
echo "http://dl-cdn.alpinelinux.org/alpine/latest-stable/main" >> /etc/apk/repositories
- Update repos:
apk update - Install Docker:
apk add --no-cache docker git curl - Make Docker run at boot:
rc-update add docker boot - Launch Docker daemon manually:
service docker start - Autorize users to manage docker:
chmod 666 /var/run/docker.sock - Switch to user:
su John - Try Docker:
docker run hello-world
Install docker-compose:
apk add --no-cache py-pip
apk add --no-cache python-dev libffi-dev openssl-dev gcc libc-dev make
pip install docker-compose
[ ] Mount /dev/sda1 to root /
So far I have come to see that the device /dev/sda has one partition /dev/sda1 but it is not mounted as root.
In fact, root seems to be mounted in ram with tmpfs.
Useful commands are:
fdisk -l
and
df -h
Since root is mounted on RAM only, it uses half the available RAM and the system (and all changes to it) is volatile: everything is wiped at reboot...
Maybe your attempt is not the right way.
After mounting the Alpine Image, go to bash.
You are now on a CD/DVD booted Livesystem, so there is only a RAM TMPFS Systemavailable.
Next you should do a simple "setup-alpine". This will do a harddisk-installation wizard on for in your case maybe sda1.
Within this wizard you can configure keyboard layout, repo a.s.o.
Best wishes... have fun!