github.com/mutagen-io/mutagen@v0.18.0-rc1/scripts/ci/setup_ssh.sh (about) 1 #!/bin/bash 2 3 # Exit immediately on failure. 4 set -e 5 6 # Determine the operating system. 7 MUTAGEN_OS_NAME="$(go env GOOS)" 8 9 # Verify that the platform is supported and that its SSH server is enabled. 10 if [[ "${MUTAGEN_OS_NAME}" == "darwin" ]]; then 11 sudo systemsetup -f -setremotelogin on 12 elif [[ "${MUTAGEN_OS_NAME}" == "linux" ]]; then 13 sudo apt-get -qq install openssh-client openssh-server 14 sudo service ssh restart 15 else 16 # TODO: We should be able to support Windows 10 via its OpenSSH server. 17 echo "SSH server CI setup not supported on this platform" 1>&2 18 exit 1 19 fi 20 21 # Ensure that home directory permissions are acceptable to sshd. 22 chmod 755 ~ 23 24 # Ensure our SSH configuration directory exists and has the correct permissions. 25 mkdir -p ~/.ssh 26 chmod 700 ~/.ssh 27 28 # Generate an SSH key in quiet mode without a password. We don't need to set 29 # permissions explicitly since ssh-keygen will set them correctly. 30 ssh-keygen -q -t ed25519 -C "ci@localhost" -N "" -f ~/.ssh/id_ed25519 31 32 # Add the key to our list of authorized keys and ensure that the authorized keys 33 # file has the correct permissions. 34 cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys 35 chmod 600 ~/.ssh/authorized_keys 36 37 # Add localhost to our list of known hosts (so we're not prompted) and ensure 38 # that the known hosts file has the correct permissions. 39 ssh-keyscan -t ed25519 localhost >> ~/.ssh/known_hosts 40 chmod 644 ~/.ssh/known_hosts