SSH Server alias

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

SSH Server alias

Post by Heavy »

I have a problem:

I access a server using ssh by typing this line:

Code: Select all

ssh -l username  hostname "some commands"
Bare with me, I'm an ssh newbie...

Now, I've read about making an "alias" to the host providing this functionality:

Code: Select all

ssh hostaliasincludingusername "some commands"
I got it from here:
http://classes.cs.kent.edu/sce/ssh.html
Cut from that page:

Code: Select all

Using SSH on Linux/UNIX

Students can access loki over a network using the full Internet name: loki.mcs.kent.edu. They would typically ssh into loki with X-Window tunneling enabled. The command to do this is:

ssh -X username@loki.mcs.kent.edu

Where username is your username on loki. The -X flag provides for X-Window tunneling.

You then have secure shell access to loki. In addition, any X-Window programs that you start in loki shell will be display, securely of course, on your local X-Windows server (the X-Windows that is running on your local computer).

ssh is very configurable and the above command can be easily shortened by configuration to:

ssh loki

To do this put the following in your ssh configuration file:

loki:
Host            loki.mcs.kent.edu
User            username
ForwardX11      yes

Check your documentation, using man or info on ssh, to see where this is.
I have crawled the Internet for about two hours not being able to find any more specific info on this subject. This is probably because I do not know what this type of "alias" is really called.

I want to add this functionality to my servers. Please, tell me which config file I should use. And if the example above (loki) is faulty, please correct it. I am getting nowhere by myself.

Thanks
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

As described in that document, just put the alias def in your config file /home/username/.ssh/config
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Post by Heavy »

Well. I tried that...

content of /home/heavy/.ssh/config:

Code: Select all

aliasedip:
Host host.domain.topdomain
User heavy
Shell cutout:

Code: Select all

їheavy@www .ssh]$ ssh aliasedip
/home/heavy/.ssh/config: line 1: Bad configuration option: aliasedip:
/home/heavy/.ssh/config: terminating, 1 bad configuration options
їheavy@www .ssh]$
Maybe its my ssh version?

Code: Select all

їheavy@www .ssh]$ ssh -V
OpenSSH_3.4p1, SSH protocols 1.5/2.0, OpenSSL 0x0090607f
їheavy@www .ssh]$
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

oh, sorry I didn't look to hard on the details of the first post, not sure what that syntax is/was for, the syntax is

Code: Select all

host  thenickname
     hostname the.real.hostname
     user theusername

  host  *.mydomain.com
     user myuser
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Post by Heavy »

Thanks! It worked well.
Post Reply