Blog Post

RE: SSH Tab Complete

This is a response to SSH Tab Complete by Michael Lustfield.

Create a ~/.ssh/config file and populate it with configurations. Doing this is the only step you need to do, and you don’t need to add anything to your ~/.bashrc. Example ~/.ssh/config:

# foobar.com
Host foobar
    Hostname foobar.com
    User xxxxxxxxxxxxx
 
# Home server (internal)
Host iserver
    Hostname 10.0.0.2
    User xxxxxxxxxxxx
    Port ####

Host is a simple word that will be used with ssh like ssh foobar. Hostname is the actual IP address of domain name of the server. User is your username for that machine. Port is the ssh port number, if it isn’t the default port of 22.

So, when I want to ssh into my home server, I just do ssh is, press tab, then enter. There are many more options to add to the config file as well, and a simple Google search will provide more. Also man ssh_config will give you pretty much everything you need as well.

This entry was posted in Application and tagged . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
  • better

    Better is to uncomment bash completion, in /etc/bash.bashrc:

    # enable bash completion in interactive shells
    if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
    fi

    Add the following to /etc/ssh/ssh_config:

    HashKnownHosts no

  • Florian

    better,
    neither my 8.04 LTS box nor my debian lenny box has an /etc/bash_completion anymore

    there’s /etc/bash_completion.d/ though, but my old script, nearly like yours, doesn’t work anymore

    nixternal,
    I’d love to hear some details about your setup then, because I can’t reproduce that on said 8.04 box, even with a fresh user with no modifications to .bashrc or environment variables at all

  • @better – even better is zsh 🙂

    @Florian – Did you try it after a reboot or a logout/login? I am not using 8.04, but on a fresh install of 9.10, it worked for me. I do not use bash as I use zsh, but on a fresh install, the default shell is dash, and it just worked for me.

  • better

    Ah yes, forgot:

    sudo apt-get install bash-completion

    http://bash-completion.alioth.debian.org

  • Pingback: Links 06/12/2009: FreeNAS Moves to GNU/Linux | Boycott Novell()

  • Wow. I already have a ~/.ssh/config for my convenience, but I didn’t know it did that. Cheers!

  • Subscribe to nixternal.com

     Subscribe in a reader

    Or, subscribe via email:
    Enter your email address:

  • Archives


semidetached
semidetached
semidetached
semidetached
%d bloggers like this: