Skip to content

Instantly share code, notes, and snippets.

@wcoastsands
Last active September 27, 2023 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wcoastsands/c75e5199f67d7afe125b8e2baf13deb6 to your computer and use it in GitHub Desktop.
Save wcoastsands/c75e5199f67d7afe125b8e2baf13deb6 to your computer and use it in GitHub Desktop.
Helper utility for SSH and SFTP
#!/bin/bash
# Provides login shortcuts via SSH and SFTP.
#
# TODO: Set the permissions on this file to 700.
# chmod 700 ssh-helper.sh
# TODO: Create symlinks for use with this script.
# ln -s ssh-helper.sh ssh
# ln -s ssh-helper.sh sftp
echo "Using the SSH Helper..."
# Trim the path from the issued command.
CMD="${0##*/}"
# Determine the command to use.
case $CMD in
"ssh") CMD=/usr/bin/ssh ;;
"sftp") CMD=/usr/bin/sftp ;;
*) $0 "$@"; exit ;;
esac
# Update login credential and reissue command.
# TODO: Replace examples in the following case statement.
case "$1" in
"router") $CMD "username@192.168.1.1" ;;
"mydomain.com") $CMD "username@mydomain.com" ;;
*) $CMD "$@" ;;
esac
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment