40 lines
1.2 KiB
Bash
Executable file
40 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
if [[ -z $FORCE ]]; then
|
|
pgrep sshd >/dev/null && exit
|
|
fi
|
|
|
|
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
|