2016-11-10 12:29:53 -08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2016-12-16 17:58:36 -08:00
|
|
|
if [[ -z $FORCE ]]; then
|
|
|
|
pgrep sshd >/dev/null && exit
|
|
|
|
fi
|
|
|
|
|
2016-11-10 12:29:53 -08:00
|
|
|
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
|