Friday, November 6, 2009

Ubuntu Linux replacement / alternative to Secure CRT

I used to be an avid user of Secure CRT in windows. I needed it for work purposes to mostly configuring Cisco Network equipment. Moving to Ubuntu had me trying all kinds of alternatives to replace CRT; like: running it in WINE, using normal ssh and telnet from the command line, and using clogin scripts.

I finally got a few Linux apps to work together that give me a similar experience I had using Windows Secure CRT. I decided to write this tutorial so I can refer back to it if I ever need to do this again, but want to share it with others as well. Try this - at your own risk.

My (personal) requirement

I needed this alternative to be able to do the following:
1- Telnet and SSH support
2- Tabs
3- Login scripts (where possible)
4- Shortcut keys (for repetitive typing tasks)
5- Search through output
6- Save output
7- Copy/Paste functionality
8- Saved login settings per device/server you want to access

Apps to install (using synaptic or your favorite installation method)

- Ubuntu
This resolves point 1 (telnet and ssh included in default Ubuntu Desktop install)

"man ssh" in a terminal if you want to see the available options, for example to change the default port number from 22 to something else, or changing the cypher from 3des to des (or any other setting).

I'm currently using Ubuntu Karmic Koala (9.10).

- Konsole (if you are using anything other than KDE)
This resolves points 2, 5, 6 and 7.

Just remember to change some of the settings in Konsole. Go to "Settings" > "Edit current profile...". I changed the Scrollback to unlimited on the Scrolling Tab. You can also change where the Tabs appear using the "Tabs" tab.

Copy/Paste work great using the mouse right click inside the Konsole terminal window. If you got very used to "Copy AND Paste" function Secure CRT had, then remember the mouse middle click function in Linux. If you highlight text in the terminal and then mouse middle click it does a Copy AND Paste function just like CRT had in its mouse right click menu.

The search function (Ctrl+Shift+F) is great - even highlights what you are searching for and it can do regular expressions.

- clogin / rancid
This resolves point 3

Login Scripts is a bit more tricky. It depends how you log in to devices in your environment. Initially I used clogin a lot. If you require a login password AND an enable password, (as is required on Cisco equipment) then this is the way to go.
Lately it is no longer a requirement for me on some devices as the username/password authentication (using TACACS) already puts the user in enable mode. So you will need to decide if you should use clogin or not. If you just want a simple ssh client (i.e. no enable password required) then clogin is not the way to go. See the next option.

If you need it, install it using synaptic. Search for the rancid and rancid-core packages.

The most important part of clogin is the .cloginrc file you must create in your home folder. When you then do a "clogin <network-device/server>" in a terminal it uses the login details in this file.

Here is some sample configs for this file: (more details can be obtained in the cloginrc man pages)

# Simple SSH login requiring enable password

add method my-router {ssh}
# the cyphertype can also be {3des} for example (the default I think)
add cyphertype my-router {des}
add user my-router my-username
add password my-router my-password {my-enable-password}


# Simple telnet login requiring enable password

add user *-router-* my-username
add password *-router-* my-password {my-enable-password}


In the last example you can see wild-cards (*) used in the hostname. So whenever a hostname has -router- in the name it will use these login details to connect. Also remember that the .cloginrc file must be in your home directory and should have 640 permission settings. In a terminal do the following after creating the file:

cd ~/

chmod 640 .cloginrc

clogin is also great for bash scripting; to log into a device and run certain commands. But that is beyond the scope of this tutorial.

- SSHMenu Applet
This resolves point 1, and some of point 8 (for SSH)

If you just want to SSH to the same devices regularly, then this client might be exactly what you need. Go here for the lowdown.

- Text Entry Shortcuts
This resolves point 4

Another feature CRT has that is often used is the shortcut keys to quickly enter text, for example your username. I used this tutorial to add this functionality in Ubuntu.

- Saving Login Settings per Device
This resolves point 8

CRT saved your logins in a folder format. The easiest way to achieve this in Ubuntu is to use a normal folder structure (in the file manager - nautilus). So create yourself all the folders you require, like "Core Routers" or "Switches", etc. Then create Desktop Launchers and move these Launchers to the correct folders once completed.

Let me give an example step-by-step:

1) Right click on the desktop and select "Create Folder"
2) Give the folder a name (e.g. Routers)
3) Right click on the desktop again and select "Create Launcher"
4) The Type must be "Application", the Name and Comment whatever you require (typically the hostname you are trying to connect to)
5) The Command must be one of the following depending on your requirement:

konsole --new-tab -e telnet <hostname/ip>
OR
konsole --new-tab -e ssh <username@host>
OR
konsole --new-tab -e clogin
<hostname/ip>

6) Then move the created Launcher into the correct folder
7) Now you can just double-click whichever Launcher so you can access a specific device. The --new-tab argument allows the login to be opened in the same konsole window, but inside a new tab.

- Finally - The hosts file

If you want to use hostnames, but do not have a DNS server on your network, you can add the IP to hostname resolution in your local /etc/hosts file. You must be root to edit this file.

That is it. You should be able to forget you ever used Secure CRT ;-)
Let me know if this worked for you or not. If there are any other alternatives you are using then share with us all. And please let me know if you think something is not clear in this tutorial.

16 comments:

  1. try this app:
    http://kuthulu.com/gcm

    ReplyDelete
  2. Kuthulu - Thanx for the headsup on the app.
    To anyone else reading this... Gnome Connection Manager or GCM remembers your connections like Secure CRT does. So when you open it you can select which device you want to connect to. It can also save it in different groups. To get it working in Kubuntu (which I am running now) I had to install python and also python-vte and libvte-common. If used in conjunction with the "Text Entry Shortcuts" described above, I believe you will get really close to CRT functionality.

    ReplyDelete
  3. the only problem is GCM does not support ssh keys to my knowledge

    ReplyDelete
  4. The developer is quite willing to improve the app, I am sure if you contact him he will look into it - or you could code it yourself ;-)

    ReplyDelete
  5. Yes it does support ssh keys (at least in Ubuntu) . Just define them in seahorse (Accessories > Password and encryption keys)
    Bernard.

    ReplyDelete
  6. gcm does support text entry shortcuts, you can define them in "settings", "shortcuts", "custom commands"
    in the "Command" column enter the text, then in "Shortcut" column define the shortcut

    ReplyDelete
  7. GCM is improving by the day it appears... looks like we are starting to have a full fledged replacement for CRT in Linux ;-)

    ReplyDelete
  8. UPDATE: I got this mail from VanDyke... Worth a look.
    -----------------------------------

    Dear Frank,

    I recently saw that one of your blog posts covers
    alternatives to SecureCRT on Ubuntu Linux.

    I just want to let you know that SecureCRT 6.7 for
    Linux is now in beta release:

    http://www.vandyke.com/products/beta/securecrt/index.html

    Please let us know if you have any questions.

    Regards,

    Jill

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Jill Christian VanDyke Software, Inc.

    ReplyDelete
    Replies
    1. Frank can you tell some other alternative so that the command to be executed get saved automatically after execution.

      Delete
    2. Hi... not exactly sure what you mean? Please explain in more detail...

      Delete
  9. Frank,

    Don't know if you knew, but check this out.

    homepage: https://sites.google.com/site/davidtv/

    Download: https://sourceforge.net/projects/pacmanager/

    Older packages are part of the Ubuntu distro and their derivatives.

    ReplyDelete
    Replies
    1. Perfect! More than I needed!
      Thanks a lot!

      Delete
  10. Schweet - will check it out :-)

    ReplyDelete
  11. PAC Manager is the perfect replacement of Secure CRT for Linux OS

    ReplyDelete