Skip to content

Instantly share code, notes, and snippets.

@pbuyle
Last active December 28, 2015 08:29
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 pbuyle/7471858 to your computer and use it in GitHub Desktop.
Save pbuyle/7471858 to your computer and use it in GitHub Desktop.
Drush only SSH access using a dedicated key.
command="/etc/drush/drush-shell" ssh-rsa AAAA...== drush
#!/bin/bash
# /etc/drush/drush-shell
# Restrict SSH access to Drush command only.
if [ -z "$SSH_ORIGINAL_COMMAND" ] ; then
export SSH_LOGIN=
echo "Error: Login to this account is not permitted!"
else
echo $SSH_ORIGINAL_COMMAND | grep --quiet '^drush'
if [ $? -eq 0 ] ; then
exec drush ${SSH_ORIGINAL_COMMAND:5:-5} 2>&1
else
echo "Error: Only Drush is allowed!"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment