Last active
September 27, 2023 19:16
-
-
Save wcoastsands/c75e5199f67d7afe125b8e2baf13deb6 to your computer and use it in GitHub Desktop.
Helper utility for SSH and SFTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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