Organize telnet and ssh connections in terminal

There are graphical applications like SecureCRT o Gnome ConnectionManager to organize our remote connections, but if like me, you prefer to do everything possible in the terminal, you will like this.

Many of us connect to a large number of computers remotely. Imagine that we have a web server in 192.168.0.100. The username with which we access is foo and also to the ssh service we have changed the port for 2244.

Whenever we want to connect we should write:

$ ssh foo@192.168.0.100 -p 2244

If we have a lot of machines to access remotely… This is not productive at all.

To better handle ssh connections from the terminal, we must create the file ~ / .ssh / config. In this file we will use the following structure:

Host webserver Hostname 192.168.0.100 User foo Port 2244

As in the example, we would fill the file with all the ssh connections that we usually make.

Now from the terminal, write ssh web server will be the same as ssh foo@192.168.0.100 -p 2244.

For connections telnet, we would have to edit our .bashrc and add for example:

r1-bcn () {telnet 10.0.0.1}

After editing this file we must do source .bashrc so that the new changes that we have made are loaded without restarting.

If we write r1-bcn in the terminal, we will connect to our telnet session.

In both cases, when tabulating it autocompletes me or shows me all the available options. It may not work in some distribution first, but looking for a bit is very easy to solve.

I don't know if there are other methods to have all your remote accesses organized, if someone knows any other way, I would love to know it:).


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   msx said

    The beauty of Unix design is that there are as many ways to do the same as there are system users 🙂
    Answering the question in your post, if you look in the Arch Linux * Extra, Community and AUR repositories you will find many console and X11 tools that allow you to manage multiple SSH accounts.

    * Some of these tools are imported from Debian and since Debian is used by many sysadmins ([trolling] something I still don't understand why! [/ Trolling]) you will surely find other related useful tools.

  2.   Damian rivera said

    I used cssh (clusterssh) to connect to several computers with ssh, I had to configure / etc / clusters (I don't remember) I will try this method. Thanks 😀

  3.   proper said

    we will have to try how are you

  4.   Algave said

    The only way to know that this will work for me is to try it, thank you so much 🙂

  5.   Ivan said

    Hello, how are you ... I'm going to do the test today ... the truth is, I had created the abbreviations with the handling of aliases within the .bash_rc in the case of my Desktop and in the .bashrc servers. And so I created it.

    alias server = 'ssh foo@192.168.0.100 -p 2244 ′

    I was carrying my again. ~ / .bashrc

    and voila ... just entering the word server so everything ... seemed like a good option since I did not know what they are presenting .... Grace… see you soon ..

  6.   R_J_P said

    I did not know about this possibility and it seems very useful, right now editing file ...
    Thank you, as always on this site you can learn a lot!