|
@@ -0,0 +1,84 @@
|
|
1
|
+#!/bin/bash
|
|
2
|
+#
|
|
3
|
+# .---. . .
|
|
4
|
+# | | |
|
|
5
|
+# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
6
|
+# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
7
|
+# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
8
|
+#
|
|
9
|
+# Freedom in the Cloud
|
|
10
|
+#
|
|
11
|
+# License
|
|
12
|
+# =======
|
|
13
|
+#
|
|
14
|
+# Copyright (C) 2015 Bob Mottram <bob@robotics.uk.to>
|
|
15
|
+#
|
|
16
|
+# This program is free software: you can redistribute it and/or modify
|
|
17
|
+# it under the terms of the GNU General Public License as published by
|
|
18
|
+# the Free Software Foundation, either version 3 of the License, or
|
|
19
|
+# (at your option) any later version.
|
|
20
|
+#
|
|
21
|
+# This program is distributed in the hope that it will be useful,
|
|
22
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
23
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
24
|
+# GNU General Public License for more details.
|
|
25
|
+#
|
|
26
|
+# You should have received a copy of the GNU General Public License
|
|
27
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
28
|
+
|
|
29
|
+CURR_USER=$USER
|
|
30
|
+
|
|
31
|
+# Version number of this script
|
|
32
|
+VERSION="1.00"
|
|
33
|
+
|
|
34
|
+# ssh (from https://stribika.github.io/2015/01/04/secure-secure-shell.html)
|
|
35
|
+SSH_CIPHERS="chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr"
|
|
36
|
+SSH_MACS="hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,umac-128@openssh.com"
|
|
37
|
+SSH_KEX="curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256"
|
|
38
|
+SSH_HOST_KEY_ALGORITHMS="ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-ed25519,ssh-rsa"
|
|
39
|
+
|
|
40
|
+# see https://stribika.github.io/2015/01/04/secure-secure-shell.html
|
|
41
|
+function ssh_remove_small_moduli {
|
|
42
|
+ sudo awk '$5 > 2000' /etc/ssh/moduli > /home/$CURR_USER/moduli
|
|
43
|
+ sudo mv /home/$CURR_USER/moduli /etc/ssh/moduli
|
|
44
|
+}
|
|
45
|
+
|
|
46
|
+function configure_ssh_client {
|
|
47
|
+ #sudo sed -i 's/# PasswordAuthentication.*/ PasswordAuthentication no/g' /etc/ssh/ssh_config
|
|
48
|
+ #sudo sed -i 's/# ChallengeResponseAuthentication.*/ ChallengeResponseAuthentication no/g' /etc/ssh/ssh_config
|
|
49
|
+ sudo sed -i "s/# HostKeyAlgorithms.*/ HostKeyAlgorithms $SSH_HOST_KEY_ALGORITHMS/g" /etc/ssh/ssh_config
|
|
50
|
+ sudo sed -i "s/# Ciphers.*/ Ciphers $SSH_CIPHERS/g" /etc/ssh/ssh_config
|
|
51
|
+ sudo sed -i "s/# MACs.*/ MACs $SSH_MACS/g" /etc/ssh/ssh_config
|
|
52
|
+ if ! grep -q "HostKeyAlgorithms" /etc/ssh/ssh_config; then
|
|
53
|
+ sudo echo " HostKeyAlgorithms $SSH_HOST_KEY_ALGORITHMS" >> /etc/ssh/ssh_config
|
|
54
|
+ fi
|
|
55
|
+ sudo sed -i "s/Ciphers.*/Ciphers $SSH_CIPHERS/g" /etc/ssh/ssh_config
|
|
56
|
+ if ! grep -q "Ciphers " /etc/ssh/ssh_config; then
|
|
57
|
+ sudo echo " Ciphers $SSH_CIPHERS" >> /etc/ssh/ssh_config
|
|
58
|
+ fi
|
|
59
|
+ sudo sed -i "s/MACs.*/MACs $SSH_MACS/g" /etc/ssh/ssh_config
|
|
60
|
+ if ! grep -q "MACs " /etc/ssh/ssh_config; then
|
|
61
|
+ sudo echo " MACs $SSH_MACS" >> /etc/ssh/ssh_config
|
|
62
|
+ fi
|
|
63
|
+
|
|
64
|
+ # Create ssh keys
|
|
65
|
+ if [ ! -f /home/$CURR_USER/.ssh/id_ed25519 ]; then
|
|
66
|
+ ssh-keygen -t ed25519 -o -a 100
|
|
67
|
+ fi
|
|
68
|
+ if [ ! -f /home/$CURR_USER/.ssh/id_rsa ]; then
|
|
69
|
+ ssh-keygen -t rsa -b 4096 -o -a 100
|
|
70
|
+ fi
|
|
71
|
+
|
|
72
|
+ ssh_remove_small_moduli
|
|
73
|
+
|
|
74
|
+ echo ''
|
|
75
|
+ echo 'Copy the following into a file called /home/username/.ssh/authorized_keys on the Freedombone server'
|
|
76
|
+ echo ''
|
|
77
|
+ echo $(cat /home/$CURR_USER/.ssh/id_rsa.pub)
|
|
78
|
+ echo $(cat /home/$CURR_USER/.ssh/id_ed25519.pub)
|
|
79
|
+ echo ''
|
|
80
|
+}
|
|
81
|
+
|
|
82
|
+echo 'Configuring client'
|
|
83
|
+configure_ssh_client
|
|
84
|
+echo 'Configuration complete'
|