-
-
Save dafta/26bec7ade1ca299926b5bc47064aeed0 to your computer and use it in GitHub Desktop.
ssh with .ssh/sshrc forwarding
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
# Forwarding your .ssh/sshrc file and sourcing it as .bashrc | |
# A function sudoi is defined on the remote machine, used | |
# instead of sudo -i, to run a shell as the specified user, | |
# or root as default, and source the local .ssh/sshrc. | |
function ssh() { | |
tmprc=$(/usr/bin/ssh "$@" "mktemp" 2>/dev/null) | |
rsync ~/.ssh/sshrc "$1:$tmprc" >/dev/null 2>&1 | |
echo "function sudoi() { sudo -u \"\${1:-root}\" bash --rcfile \"$tmprc\"; }" | /usr/bin/ssh "$@" "cat - >> \"$tmprc\"" >/dev/null 2>&1 | |
/usr/bin/ssh -t "$@" "chmod a+r \"$tmprc\"; bash --rcfile \"$tmprc\" ; rm \"$tmprc\"" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment