Skip to content

Instantly share code, notes, and snippets.

@itkq
Created December 26, 2016 06:21
Show Gist options
  • Save itkq/b6b0db03a74a6b5a15affde33baffc17 to your computer and use it in GitHub Desktop.
Save itkq/b6b0db03a74a6b5a15affde33baffc17 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
if [ ! `which envchain` ]; then
echo 'envchain not found'
exit 1
fi
if [ $# -ne 1 ]; then
echo "Usage: envchain-ssh host" 1>&2
exit 1
fi
HOST=$1
PW=`envchain ssh printenv $1`
expect -c "
set timeout 5
spawn ssh ${HOST}
expect \"password:\"
send \"${PW}\n\"
expect \"$\"
interact
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment