SSH and BASH - Printable Version +- Linux-Noob Forums (https://www.linux-noob.com/forums) +-- Forum: Linux Noob (https://www.linux-noob.com/forums/forum-3.html) +--- Forum: Tips and Tricks (https://www.linux-noob.com/forums/forum-59.html) +--- Thread: SSH and BASH (/thread-1506.html) |
SSH and BASH - znx - 2007-03-22 How many times have I seen people using SSH aliases to shorthand the long statements they need to type to login: Code: alias ssh-home="ssh -p 12345 znx@somelong.hostname.com" Now whilst this eases the pain, you are missing some real magic that SSH and BASH can provide you! So lets get started: Edit/Make the ~/.ssh/config Code: Host some Now what's that all about you say, well now the original long top line can be replaced with: Code: ssh some MAGIC! But that's not all, you can infact setup BASH to provide you with a tab completion on those new short hostnames! Edit/Add to your ~/.bashrc Code: HOSTFILE=~/.hosts Edit/Add to a ~/.hosts Code: 192.168.1.2 some.long.host hostname To update the current shell you are running do: Code: source ~/.bashrc Now here is the magic: Code: ssh s<TAB BUTTON> At which point you will be given the option of "some" or "some.long.host". Better than all that is this, when you edit your ~/.ssh/config or your ~/.hosts to update or add a new host, it is INSTANTLY in your tab complete. Weeeeee! Code: ssh home ;) Love Linux ;) SSH and BASH - xDamox - 2007-03-23 Nice tip/trick :) |