forked from TheReal1604/disk-encryption-hetzner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00_client.sh
executable file
·41 lines (35 loc) · 1015 Bytes
/
00_client.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# Contribution to:
# https://unix.stackexchange.com/questions/411945/luks-ssh-unlock-strange-behaviour-invalid-authorized-keys-file
# https://projectgus.com/2013/05/encrypted-rootfs-over-ssh-with-debian-wheezy/
echo "Please give me the Hostname of your server"
read HOSTNAME
echo "Please give me the IP of your server"
read IP
# Generate SSH Key
ssh-keygen -t rsa -b 4096 -f ~/.ssh/hetzner_unlock
ssh-keygen -t rsa -b 4096 -f ~/.ssh/hetzner_login
echo "
Host unlock_$HOSTNAME
User root
Hostname $IP
HostKeyAlias unlock_$HOSTNAME
Port 22
PreferredAuthentications publickey
IdentityFile ~/.ssh/hetzner_unlock
Host rescue_$HOSTNAME
User root
Hostname $IP
HostKeyAlias rescue_$HOSTNAME
Port 22
PreferredAuthentications publickey
IdentityFile ~/.ssh/hetzner_login
Host $HOSTNAME
User root
Hostname $IP
HostKeyAlias hetzner_$HOSTNAME
Port 22
PreferredAuthentications publickey
IdentityFile ~/.ssh/hetzner_login " >> ~/.ssh/config
# Test connection
ssh rescue_${HOSTNAME} -v