bash autocomplete for SSH

If you are like me, and you SSH to machines through out the day, you want this. Ok. You __need__ this.

The following one liner, parses your .bash_history file and attempts to autocomplete the host you are trying to SSH to. Add this line to your .bash_profile/.bashrc file.

complete -W "$(echo $(grep '^ssh ' .bash_history | sort -u | sed 's/^ssh //'))" ssh

Of course the lookup is limited to machines you have already SSH’d to. But whatevs, it __will__ save you time and keystrokes. Time which you could use to watch re-runs of My Little Pony.

SSH as root on EC2 Ubuntu AMIs (EDIT: works on Amazon Official AMIs as well)

Ever find yourself wanting to SSH as root into an instance launched with the official Ubuntu EC2 AMI, and you get this?

Please login as the user “ubuntu” rather than the user “root”.

If you know what you are doing and want to SSH as root, follow these steps.

  • ssh ubuntu@ (using your private key)
  • sudo -s (to become root)
  • emacs/vi /root/.ssh/authorized_keys
  • delete the lines at the begining of the file that say “COMMAND….” until you get to the words ssh-rsa
  • emacs /etc/ssh/sshd_config
  • set the variable “PermitRootLogin” to “without-password” (without quotes of course)
  • sudo /etc/init.d/sshd restart (bounce sshd)