Results 1 to 10 of 11

Thread: Symbolic Link for SSH Remote Hostname

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Beans
    193
    Distro
    Ubuntu 10.04 Lucid Lynx

    [SOLVED] Symbolic Link for SSH Remote Hostname

    Hi,

    Is there a way to create a symbolic link to an off-site server, such that I don't have to type in user@xxx.yyy.zzz.aaa.bbb.ccc?

    Thanks!

    PS: I need to know how to do this on OSX, and on Ubuntu 10.04. I'm pretty sure it's the same command.
    Last edited by lazyrussian; January 25th, 2011 at 02:58 AM.

  2. #2
    Join Date
    Feb 2007
    Beans
    4,045
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Symbolic Link for SSH Remote Hostname

    If the IP is static, add an entry in /etc/hosts. E.g.
    Code:
    123.123.123.123 xxx.yyy.zzz.aaa.bbb.ccc shortname
    Then you can do
    Code:
    ssh user@shortname

    Another option is of course to make a shell function (or alias).
    Code:
    sshfoo() { ssh user@xxx.yyy.zzz.aaa.bbb.ccc "$@"; }
    Add it to the end of ~/.bashrc to make it permanent.

  3. #3
    Join Date
    Mar 2006
    Beans
    193
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Symbolic Link for SSH Remote Hostname

    Thanks! Modifying /etc/hosts worked perfectly!

  4. #4
    Join Date
    Feb 2010
    Beans
    91

    Re: Symbolic Link for SSH Remote Hostname

    ssh has its own mechanism for this, you don't need to touch /etc/hosts. You can do something like in your local ssh_config

    Code:
    host shortcut
        hostkeyalias name_in_known_hosts_file
        hostname longame_or_ip_address
        port non_standard_port_number
    This tells ssh that hostname shortcut has a known_hosts keyname of hostkeyalias, a real ip address or DNS host name of longame_or_ip_address, and an ssh listen port number of non_standard_port_number. This entry would reduce the ssh login command from

    Code:
    ssh -p non_standard_port_number -o HostKeyAlias name_in_known_hosts_file \\
    user@longame_or_ip_address
    to
    Code:
    ssh user@shortcut
    The hostkeyalias and port entries are extremely useful if you are contacting a host via port forwarding through a gateway machine. man ssh_config for more.

  5. #5
    Join Date
    Mar 2006
    Beans
    193
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Symbolic Link for SSH Remote Hostname

    Quote Originally Posted by talonmies View Post
    ssh has its own mechanism for this, you don't need to touch /etc/hosts. You can do something like in your local ssh_config

    Code:
    host shortcut
        hostkeyalias name_in_known_hosts_file
        hostname longame_or_ip_address
        port non_standard_port_number
    This tells ssh that hostname shortcut has a known_hosts keyname of hostkeyalias, a real ip address or DNS host name of longame_or_ip_address, and an ssh listen port number of non_standard_port_number. This entry would reduce the ssh login command from

    Code:
    ssh -p non_standard_port_number -o HostKeyAlias name_in_known_hosts_file \\
    user@longame_or_ip_address
    to
    Code:
    ssh user@shortcut
    The hostkeyalias and port entries are extremely useful if you are contacting a host via port forwarding through a gateway machine. man ssh_config for more.
    Thanks, I'll look into it later today!

  6. #6
    Join Date
    Jan 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Symbolic Link for SSH Remote Hostname

    yeah, don't use hosts for "shortcuts" for ssh, if it's needed system and DNS is not an option for w/e reason, then use hosts. otherwise, use ssh_config.
    I am infallible, you should know that by now.
    "My favorite language is call STAR. It's extremely concise. It has exactly one verb '*', which does exactly what I want at the moment." --Larry Wall
    (02:15:31 PM) ***TimToady and snake oil go way back...
    42 lines of Perl - SHI - Home Site

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •