helm/shell/ssh/install

44 lines
1.3 KiB
Plaintext
Raw Normal View History

2016-11-10 12:29:53 -08:00
#!/usr/bin/env bash
if [[ -z $FORCE ]]; then
pgrep sshd >/dev/null && exit
fi
2016-11-10 12:29:53 -08:00
case $OSTYPE in
darwin*)
macos-load-ssh() {
# Comes preinstalled on MacOS
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
}
# Activate service when script is finished
trap macos-load-ssh EXIT
2016-11-10 12:29:53 -08:00
;;
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