Skip to content

Instantly share code, notes, and snippets.

@hihellobolke
Created January 31, 2014 20:39
Show Gist options
  • Select an option

  • Save hihellobolke/8742680 to your computer and use it in GitHub Desktop.

Select an option

Save hihellobolke/8742680 to your computer and use it in GitHub Desktop.
sudo2ssh - a sudo that is basically ssh as root to localhost, written as bash function
sudo () {
echo "sudossh wrapper i.e. 'ssh root@localhost'";
curdir=$(pwd);
sudossh="ssh -q -t";
if [[ "${1-bash}" == "bash" ]]; then
$sudossh root@localhost "PATH=$PATH; export PATH; PS1=(ROOT)$PS1; export PS1; cd $curdir && bash";
else
$sudossh root@localhost "PATH=$PATH; export PATH; PS1=(ROOT)$PS1; export PS1; cd $curdir && $@";
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment