LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   IP alias? Machine name alias? (https://www.linuxquestions.org/questions/linux-newbie-8/ip-alias-machine-name-alias-477647/)

JohnLocke 08-26-2006 05:52 PM

IP alias? Machine name alias?
 
I'm sure this is a fairly simple question and answer, but I don't even know the right words to ask it. I've got two computers that aren't on the same network which I log in to remotely (using ssh). I know I can make an alias, but I'm wondering if there's a more "correct" way to tell the computer that "Lenny" is at 6.16.xxx.xxx and "Bugz" is at 168.2.xxx.xxx.

Is there something like an /etc/machine file where I can set that information so later I can just type "ssh Lenny" or "sftp Bugz" and get to the right box?

Thanks ... and if you could tell me the correct way of /describing/ this problem, I'd be happy to look at a manual already out there somewhere.

HappyTux 08-26-2006 06:05 PM

The file /etc/hosts is used for that put the machine address then name on a line by themselves then you can use them in the command an example of the file.

Code:

6.16.xxx.xxx Lenny
168.2.xxx.xxx Bugz

Of course changing the xxx to the proper numbers do this on both machines if you want to do it from each to the other.

ph0b0s 08-26-2006 06:07 PM

Quote:

Originally Posted by JohnLocke
I'm sure this is a fairly simple question and answer, but I don't even know the right words to ask it. I've got two computers that aren't on the same network which I log in to remotely (using ssh). I know I can make an alias, but I'm wondering if there's a more "correct" way to tell the computer that "Lenny" is at 6.16.xxx.xxx and "Bugz" is at 168.2.xxx.xxx.

Is there something like an /etc/machine file where I can set that information so later I can just type "ssh Lenny" or "sftp Bugz" and get to the right box?

Thanks ... and if you could tell me the correct way of /describing/ this problem, I'd be happy to look at a manual already out there somewhere.

/etc/hosts :D

edit : ok happytux was faster ;)

JohnLocke 08-26-2006 07:01 PM

Grrr ... I probably should have known that.

Anyway ... thanks much for the answer! That works brilliantly.

jakev383 01-16-2008 12:21 PM

You can also add them to your ssh file (/etc/ssh/ssh_config in RH distros) like this:
Code:

host fileserver
    hostname 192.168.0.4
    Port 5781
    UserKnownHostsFile ~/.ssh/fileserver

Especially useful when you put SSH on a port other than 22 - you can then just:
Code:

ssh fileserver
and it will connect to IP address 192.168.0.4 on pot 5781 for you. I find this especially useful if you manage multiple machines.


All times are GMT -5. The time now is 08:16 PM.