Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- SSH_CMD=${SSH_CMD:=ssh}
- SSH_USER=${SSH_USER:=USER}
- SSH_PASSWORD=${SSH_PASSWORD:=fakepassword}
- SCRIPTDIR=$(dirname $0)
- trap cleanup INT TERM EXIT
- askpass() {
- echo $SSH_PASSWORD
- }
- cleanup() {
- rm $SSHCFG
- }
- if [ -z "$SSH_USER" ]; then
- echo Could not obtain username from SSH_USER>&2
- exit 1
- fi
- # when ssh run the SSH_ASKPASS command, it will have itself in the SSH_ASKPASS environment variable. we can detect which type of "invokation" we're in
- if [ -z "$SSH_ASKPASS" ]; then
- # DISPLAY isn't used and its content is irrelevant. but ssh requires it to be set
- export DISPLAY="dummy:0"
- # set the script to run to ourselves. this will hit the second branch of the if block
- export SSH_ASKPASS=$0
- if [[ "$SSH_CMD" == "ssh" ]]; then
- setsid $SSH_CMD -F $SSHCFG -l $USER "$@"
- else
- echo "Note: Not using ssh command, make sure you're using the username $USER" >&2
- setsid $SSH_CMD "$@"
- fi
- else
- askpass
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement