#!/usr/bin/env bash echo Installing Tailscale SSH... TAILSCALE_SSH_DIR=${TAILSCALE_SSH_DIR-"$HOME/.tailscale-ssh"} TAILSCALE_SSH_BIN_DIR="$TAILSCALE_SSH_DIR/bin" BIN_URL="https://raw.githubusercontent.com/jtguibas/tailscale-ssh/main/tailscale-ssh" BIN_PATH="$TAILSCALE_SSH_BIN_DIR/tsh" # Create the .tailscale-ssh bin directory and tailscale-ssh binary if it doesn't exist. mkdir -p $TAILSCALE_SSH_BIN_DIR curl -# -L $BIN_URL -o $BIN_PATH chmod +x $BIN_PATH # Store the correct profile file (i.e. .profile for bash or .zshenv for ZSH). case $SHELL in */zsh) PROFILE=${ZDOTDIR-"$HOME"}/.zshenv PREF_SHELL=zsh ;; */bash) PROFILE=$HOME/.bashrc PREF_SHELL=bash ;; */fish) PROFILE=$HOME/.config/fish/config.fish PREF_SHELL=fish ;; */ash) PROFILE=$HOME/.profile PREF_SHELL=ash ;; *) echo "tailscale-ssh: could not detect shell, manually add ${TAILSCALE_SSH_BIN_DIR} to your PATH." exit 1 esac # Only add tailescale-ssh if it isn't already in PATH. if [[ ":$PATH:" != *":${TAILSCALE_SSH__BIN_DIR}:"* ]]; then # Add the tailscale-ssh directory to the path and ensure the old PATH variables remain. echo >> $PROFILE && echo "export PATH=\"\$PATH:$TAILSCALE_SSH_BIN_DIR\"" >> $PROFILE fi echo && echo "Detected your preferred shell is ${PREF_SHELL} and added tailscale-ssh to PATH. Run 'source ${PROFILE}' or start a new terminal session to use tailscale-ssh." echo "Then, simply run 'tsh' to connect to servers in our Tailscale network."