0

Right now I have a network server that I frequently have to SSH into. Instead of typing:

ssh fox@192.168.2.24

I want to be able to say:

ssh fox@srv

And that it would SSH into the server at 192.168.2.24.

Is this possible, and if yes, how do I do that?

foxite
  • 451
  • 2
  • 9
  • 25

1 Answers1

0

Thanks for @steeldriver for pointing me at this (and correcting me).

To do this:

  • Inside the .ssh folder in your home directory, create the file "config" if it doesn't exist.
  • Add this to the file:

    Host srv
      Hostname 192.168.2.24
    

This will make it possible to type ssh fox@srv instead of the whole address. You can also add:

User fox

To just type ssh srv.

See the man page for ssh_config for full details.

foxite
  • 451
  • 2
  • 9
  • 25
  • Actually I would have recommended creating an entry for the server in your `~/.ssh/config` file instead – steeldriver Feb 06 '16 at 19:42
  • @steeldriver That sounds like it would work but I don't have that file. I do have a `known_hosts` file there though. – foxite Feb 06 '16 at 20:46
  • Aand after reading through your answer that seems like the much better option. Thanks! – foxite Feb 06 '16 at 20:52