From c5ebb7a5b65082b362159489caace319b53f4d7f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 10 Nov 2016 21:29:53 +0100 Subject: [PATCH] +shell/ssh --- shell/ssh/install | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 shell/ssh/install diff --git a/shell/ssh/install b/shell/ssh/install new file mode 100755 index 00000000..7c6ea535 --- /dev/null +++ b/shell/ssh/install @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +case $OSTYPE in + darwin*) + # Comes preinstalled on MacOS + sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist + ;; + linux*) + if [[ -f /etc/arch-release ]]; then + sudo pacman --needed --noconfirm -S openssh + sudo systemctl enable sshd.service + sudo systemctl start sshd.service + elif [[ -f /etc/debian_version ]]; then + sudo apt-get install -y openssh-server + sudo service ssh start + sudo update-rc.d ssh defaults + fi + ;; +esac + +sshconf=/etc/ssh/sshd_config +sudo sed -i 's/^#\(AllowTcpForwarding\).*/\1 yes/; + s/^#\(RSAAuthentication\).*/\1 yes/; + s/^#\(PubkeyAuthentication\).*/\1 yes/; + s/^#\(PasswordAuthentication\).*/\1 no/; + s/^#\(PermitRootLogin\).*/\1 no/; + ' "$sshconf" + +# Enable X11 forwarding on desktop PCs (not remotes) +if [[ $OSTYPE == darwin* || -f /etc/arch-release ]]; then + sudo sed -i 's/^#\(X11Forwarding\).*/\1 yes/; + s/^#\(X11DisplayOffset.*\)/\1/; + s/^#\(X11UseLocalhost\).*/\1 yes/; + ' "$sshconf" +fi