In SSH, how to replace a full domain name with an alias
Usually, I need to type "ssh eden.rutgers.edu" 20 times everyday. It is bothering to type the whole domain name everytime.
What changes can I do in Linux to make "ssh eden" works instead? Thanks a lot! |
You can set an alias in your .bash_profile (or the profile for whatever shell you are using). For example:
alias eden='ssh eden.rutgers.edu' You can issue the command manually, to have it take effect immediately (it will automatically get set at your next login). Now you can just enter: eden and the ssh command will get executed. |
Hi zbinwu,
besides adding an alias, you can also add an entry to your "/etc/hosts" file. the syntax is := IP address FQDN Hostname ie... you can use:= 192.168.10.11 eden.rutgers.edu eden now you can use the command " ssh eden" to connect.. vimal.... |
Another search entry in /etc/resolv.conf was the better solution for me.
Read man resolv.conf for more details. |
Another way is simply make or edit ~/.ssh/config with
Code:
host big Code:
ssh big |
@protozorq /etc/resolv.conf file is where you enter the DNS name, you will have to use the way vimal suggested or use the alias as macemoneta suggested. what you did is not correct though it will give you the desire output.
|
Excerpt from the manpage:
"search Search list for host-name lookup. The search list is normally determined from the local domain name; by default, it contains only the local domain name. This may be changed by listing the desired domain search path follow‐ ing the search keyword with spaces or tabs separating the names." This is for intranet networks with multiple sub-domains and thus it works great for me. The actual reason I looked again into this forum is, that it does not work with DHCP clients. Those need an entry like append search-domain "incredible.super.long.org" in /etc/dhcp/dhclient.conf instead. Greetings. |
But you don't need to mess with your DNS at all...
|
All times are GMT -5. The time now is 04:01 PM. |