2015-01-24 21:02:39 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# .---. . .
|
|
|
|
# | | |
|
|
|
|
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
|
|
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
|
|
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
|
|
#
|
|
|
|
# Freedom in the Cloud
|
|
|
|
#
|
|
|
|
# License
|
|
|
|
# =======
|
|
|
|
#
|
2016-01-02 22:58:27 +01:00
|
|
|
# Copyright (C) 2015-2016 Bob Mottram <bob@robotics.uk.to>
|
2015-01-24 21:02:39 +01:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2016-02-13 23:09:27 +01:00
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
2015-01-24 21:02:39 +01:00
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2016-02-13 23:09:27 +01:00
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
2015-01-24 21:02:39 +01:00
|
|
|
#
|
2016-02-13 23:09:27 +01:00
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2015-01-24 21:02:39 +01:00
|
|
|
|
2015-11-27 12:42:16 +01:00
|
|
|
PROJECT_NAME='freedombone'
|
|
|
|
|
2015-11-27 17:52:23 +01:00
|
|
|
export TEXTDOMAIN=${PROJECT_NAME}-client
|
2015-11-27 12:42:16 +01:00
|
|
|
export TEXTDOMAINDIR="/usr/share/locale"
|
|
|
|
|
2015-01-24 21:02:39 +01:00
|
|
|
CURR_USER=$USER
|
2016-04-30 11:08:19 +02:00
|
|
|
MESH_CLIENT_INSTALL=
|
2015-01-24 21:02:39 +01:00
|
|
|
|
|
|
|
# Version number of this script
|
2015-07-09 19:59:43 +02:00
|
|
|
VERSION="1.01"
|
2015-01-24 21:02:39 +01:00
|
|
|
|
|
|
|
# ssh (from https://stribika.github.io/2015/01/04/secure-secure-shell.html)
|
|
|
|
SSH_CIPHERS="chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr"
|
|
|
|
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"
|
|
|
|
SSH_KEX="curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256"
|
|
|
|
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"
|
|
|
|
|
|
|
|
# see https://stribika.github.io/2015/01/04/secure-secure-shell.html
|
|
|
|
function ssh_remove_small_moduli {
|
2016-04-30 11:03:27 +02:00
|
|
|
sudo awk '$5 > 2000' /etc/ssh/moduli > /home/$CURR_USER/moduli
|
|
|
|
sudo mv /home/$CURR_USER/moduli /etc/ssh/moduli
|
2015-01-24 21:02:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function configure_ssh_client {
|
2016-04-30 11:03:27 +02:00
|
|
|
#sudo sed -i 's/# PasswordAuthentication.*/ PasswordAuthentication no/g' /etc/ssh/ssh_config
|
|
|
|
#sudo sed -i 's/# ChallengeResponseAuthentication.*/ ChallengeResponseAuthentication no/g' /etc/ssh/ssh_config
|
|
|
|
sudo sed -i "s/# HostKeyAlgorithms.*/ HostKeyAlgorithms $SSH_HOST_KEY_ALGORITHMS/g" /etc/ssh/ssh_config
|
|
|
|
sudo sed -i "s/# Ciphers.*/ Ciphers $SSH_CIPHERS/g" /etc/ssh/ssh_config
|
|
|
|
sudo sed -i "s/# MACs.*/ MACs $SSH_MACS/g" /etc/ssh/ssh_config
|
|
|
|
if ! grep -q "HostKeyAlgorithms" /etc/ssh/ssh_config; then
|
|
|
|
sudo cp /etc/ssh/ssh_config ~/ssh_config
|
|
|
|
sudo chown $CURR_USER:$CURR_USER ~/ssh_config
|
|
|
|
echo " HostKeyAlgorithms $SSH_HOST_KEY_ALGORITHMS" >> ~/ssh_config
|
|
|
|
sudo mv ~/ssh_config /etc/ssh/ssh_config
|
|
|
|
sudo chown root:root /etc/ssh/ssh_config
|
|
|
|
fi
|
|
|
|
sudo sed -i "s/Ciphers.*/Ciphers $SSH_CIPHERS/g" /etc/ssh/ssh_config
|
|
|
|
if ! grep -q "Ciphers " /etc/ssh/ssh_config; then
|
|
|
|
sudo cp /etc/ssh/ssh_config ~/ssh_config
|
|
|
|
sudo chown $CURR_USER:$CURR_USER ~/ssh_config
|
|
|
|
echo " Ciphers $SSH_CIPHERS" >> ~/ssh_config
|
|
|
|
sudo mv ~/ssh_config /etc/ssh/ssh_config
|
|
|
|
sudo chown root:root /etc/ssh/ssh_config
|
|
|
|
fi
|
|
|
|
sudo sed -i "s/MACs.*/MACs $SSH_MACS/g" /etc/ssh/ssh_config
|
|
|
|
if ! grep -q "MACs " /etc/ssh/ssh_config; then
|
|
|
|
sudo cp /etc/ssh/ssh_config ~/ssh_config
|
|
|
|
sudo chown $CURR_USER:$CURR_USER ~/ssh_config
|
|
|
|
echo " MACs $SSH_MACS" >> ~/ssh_config
|
|
|
|
sudo mv ~/ssh_config /etc/ssh/ssh_config
|
|
|
|
sudo chown root:root /etc/ssh/ssh_config
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Create ssh keys
|
|
|
|
if [ ! -f /home/$CURR_USER/.ssh/id_ed25519 ]; then
|
|
|
|
ssh-keygen -t ed25519 -o -a 100
|
|
|
|
fi
|
|
|
|
if [ ! -f /home/$CURR_USER/.ssh/id_rsa ]; then
|
|
|
|
ssh-keygen -t rsa -b 4096 -o -a 100
|
|
|
|
fi
|
|
|
|
|
|
|
|
ssh_remove_small_moduli
|
|
|
|
|
|
|
|
echo ''
|
|
|
|
echo $'Copy the following into a file called /home/username/.ssh/authorized_keys on the Freedombone server'
|
|
|
|
echo ''
|
|
|
|
echo $(cat /home/$CURR_USER/.ssh/id_rsa.pub)
|
|
|
|
echo $(cat /home/$CURR_USER/.ssh/id_ed25519.pub)
|
|
|
|
echo ''
|
2015-01-24 21:02:39 +01:00
|
|
|
}
|
|
|
|
|
2016-04-30 11:03:27 +02:00
|
|
|
function configure_monkeysphere {
|
|
|
|
sudo apt-get -y install monkeysphere
|
2015-07-19 20:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function show_help {
|
2016-04-30 11:03:27 +02:00
|
|
|
echo ''
|
2016-04-30 11:08:19 +02:00
|
|
|
echo $"${PROJECT_NAME}-client --mesh [yes|no]"
|
2016-04-30 11:03:27 +02:00
|
|
|
echo ''
|
|
|
|
exit 0
|
2015-07-19 20:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
while [[ $# > 1 ]]
|
|
|
|
do
|
2016-04-30 11:03:27 +02:00
|
|
|
key="$1"
|
|
|
|
|
|
|
|
case $key in
|
|
|
|
-h|--help)
|
|
|
|
show_help
|
|
|
|
;;
|
|
|
|
--essid)
|
|
|
|
shift
|
|
|
|
WIFI_SSID="$1"
|
|
|
|
;;
|
|
|
|
--channel)
|
|
|
|
shift
|
|
|
|
WIFI_CHANNEL=${1}
|
|
|
|
;;
|
2016-04-30 11:08:19 +02:00
|
|
|
--mesh)
|
|
|
|
shift
|
|
|
|
MESH_CLIENT_INSTALL=${1}
|
|
|
|
;;
|
2016-04-30 11:03:27 +02:00
|
|
|
*)
|
|
|
|
# unknown option
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
2015-07-19 20:37:57 +02:00
|
|
|
done
|
|
|
|
|
2015-11-27 16:29:43 +01:00
|
|
|
echo $'Configuring client'
|
2015-01-24 21:02:39 +01:00
|
|
|
configure_ssh_client
|
2016-04-30 11:03:27 +02:00
|
|
|
configure_monkeysphere
|
2016-04-30 11:08:19 +02:00
|
|
|
if [[ $MESH_CLIENT_INSTALL == $'yes' || $MESH_CLIENT_INSTALL == $'y' || $MESH_CLIENT_INSTALL == $'on' ]]; then
|
|
|
|
${PROJECT_NAME}-mesh-install batman_client
|
|
|
|
${PROJECT_NAME}-mesh-install babel_client
|
|
|
|
fi
|
2015-11-27 16:29:43 +01:00
|
|
|
echo $'Configuration complete'
|
2015-07-19 20:37:57 +02:00
|
|
|
exit 0
|