IOS: Reverse SSH Console Access

Reverse Telnet

Reverse telnet has been around for long time. The most common use today is to provide access to the console ports on your Cisco equipment in the data center so that you can configure them in the case of a radical failure.

This is easy to do. You pick a standard router that has Network Module slots, purchase an NM-16A or NM-32A Asynchronous module. This has four unusual connectors and looks like this.

Understanding 16- and 32-Port Async Network Modules - Cisco Systems-1.png

The CAB-OCTAL-ASYNC cable looks like this and the kit comes standard with eight DB25 connectors which plug in to RJ45 connectors on the end of the cable. Its the RJ45 connectors that you want. You can throw the Rj45-DB25 connectors in the bin.

CAB-OCTAL-ASYNC Cable Pinouts - Cisco Systems.png

Once you put the module, and powered up you can see these lines:

lontrm01#show line summary
        0: ?... .... .... .... .... .... .... .... .UU-
       36: ---? ??-? ???? ???? ???? ???? ???? ??-U -???
       72: ???? ???? ???? ???? ???? ???? ???

   3 character mode users.           (U)
  57 lines never used.               (?)
   7 lines used, but currently idle. (-)
  32 lines do not exist.             (.)
   3 total lines in use, 0 not authenticated (lowercase)
lontrm01#

IOS allocated line numbers is a quasi random sort of way. You should refer to How Async Lines are Numbered on 3600 series Router as a starting point.

The easiest way to see how the TTY lines are laid out is to install the modules and do a “show line”. Remember also that modules count from zero, and start on the bottom right, then up, and back to the bottom on the left and then up.

Connections

Plug the RJ45 connection into the console port of your Cisco device.

Configuring IOS for Reverse Telnet

r1#conf t
r1(config)#line 33 64
r1(config-line)#transport input telnet
r1(config-line)#no exec
r1(config-line)#^Z
r1#

Go your telnet client – telnet 198.18.1.1 2033 will connect you to line 33, telnet 198.18.1.1 2034 will connect you to line 2034.

We have confirmed connectivity.

Reverse SSH

The SSH listener doesn’t use the same ports, we have to use rotary groups.

!generate the ssh key or
crypto key generate rsa
!some of the usual stuff for ssh
ip ssh time-out 60
ip ssh authentication-retries 4
!configure the ssh listener at port 2001 through 2127
ip ssh port 2001 rotary 1 127
ip ssh logging events
!
line 33
! set the rotary group the port belongs to, only one port per rotary group
 rotary 1
! do not allow the serial line to create spawn an exec session as this will lock the port.
!This happens when the serial line gets EMF / EMI.
 no exec
!allow SSH thread to access the port.
 transport input ssh
 transport output none
line 34
 rotary 2
 no exec
 transport input ssh
 transport output none
line 35
 rotary 3
 no exec
 transport input ssh
 transport output none
!repeat for every line

You will need to configure your SSH client to connect on a non-standard port:

reversessh01.jpg

or even better at the Command Line

ssh -l gf 198.18.1.1 -p 2001

or

ssh [email protected] -p 2001

Each console port is available in ascending order, thus ssh -l gf 10.216.4.10 -p 2002 will connect to line 34, ssh -l gf 10.216.4.10 -p 2003 will connect to line 35.

Clearing Lines

Sometimes a line will not be terminated cleanly and will need clearing. Do a show line and the asterisk or star will show you which line is ‘in use’.

r1#sh line
   Tty Typ     Tx/Rx    A Modem  Roty AccO AccI   Uses   Noise  Overruns   Int
      0 CTY              -    -      -    -    -      0       0     0/0       -
*    33 TTY   9600/9600  -    -      1    -    -     14       0     0/0       -
*    34 TTY   9600/9600  -    -      2    -    -      3       0     0/0       -
     35 TTY   9600/9600  -    -      3    -    -      1       1     0/0       -
     36 TTY   9600/9600  -    -      4    -    -      1       0     0/0       -
-snip-
r1#clear line 33
[confirm]
 [OK]
r1#
r1#show line
   Tty Typ     Tx/Rx    A Modem  Roty AccO AccI   Uses   Noise  Overruns   Int
      0 CTY              -    -      -    -    -      0       0     0/0       -
     33 TTY   9600/9600  -    -      1    -    -     14       0     0/0       -
*    34 TTY   9600/9600  -    -      2    -    -      3       0     0/0       -
     35 TTY   9600/9600  -    -      3    -    -      1       1     0/0       -
     36 TTY   9600/9600  -    -      4    -    -      1       0     0/0       -

Why not use something else ?

Many people use a Cyclades or some other product to do this. They are often cheaper and have high density. However, I often waste a lot of time getting the physical cabling sorted out to connect to a Cisco console port. The Cisco NM-16A is quick and easy solution. Typically I use a 2600 or 3600 series router to be my terminal server, so the cost is really only for a the Asynchronous NM module and some cables.

I would also recommend buying the CAB-OCTAL-ASYNC cable from ebay. Typically £25 versus £150 or more from Cisco resellers. The ebay version can also come in five metre lengths which is useful for running up to your patch panel.

Conclusion

The use of reverse telnet or SSH is vital to creating an effective lights out and hands off data centre. It is also critical when building an Out of Band Network Disaster network as this might be the only way to connect to network equipment in the event of meltdown.

Telnet is not suitable because of its poor security (clear text passwords) so SSH is a necessity.

Please let me know if I have made any typos. Would be happy to fix this up.

Postscript

I published a follow up to this post at http://etherealmind.com/cisco-ios-reverse-ssh-terminal-server-console-access-part2/

Other posts in the series

  1. Cisco IOS CLI Regex: sh ip bgp in
  2. IOS CLI Tip: More accurate pipe commands
  3. Cisco Nexus NXOS and Fixing broken “switchto” syntax with alias
  4. show ip eigrp topology all
  5. Cisco IOS CLI Shortcuts
  6. The poor man's IOS Traffic Generator
  7. IOS: "terminal monitor" on, off - logging to your terminal
  8. IOS: Console, Terminal, Monitor, VTY - what is what ?
  9. IOS: Clearing an interface configuration
  10. IOS: Setting Terminal Window Length
  11. IOS CLI: show run linenum
  12. IOS: Setting the TCP timeout on IOS
  13. IOS: enable and .... disable ?
  14. IOS: Reverse SSH console access - Part 2
  15. IOS:Open Source Lab DNS and IP addressing
  16. IOS: Reverse SSH console access (This post)
  17. ip tcp timestamp
  18. Cisco ASA and IOS command tip - test aaa-server
About Greg Ferro

Greg Ferro is a Network Engineer/Architect, mostly focussed on Data Centre, Security Infrastructure, and recently Virtualization. He has over 20 years in IT, in wide range of employers working as a freelance consultant including Finance, Service Providers and Online Companies. He is CCIE#6920 and has a few ideas about the world, but not enough to really count.

He is a host on the Packet Pushers Podcast, blogger at EtherealMind.com and on Twitter @etherealmind and Google Plus

  • Emanuele

    Hi Greg,
    nice article… I would like to share my experience:
    I, usually, do reverse-ssh without rotary. You can just put
    transport input SSH
    in line configuration.

    You can select which line to use with “:linenumber” after username, for example to use reverse SSH on 2600 AUX port, just use
    ssh -l user:65 2600-ip

    Every reverse connection will use port 22, this is really handy when the terminal server is behind a firewall.
    Here some info from cisco:
    http://www.cisco.com/en/US/docs/ios/12_3t/12_3t11/feature/guide/gt_rssh.html


    Bye,
    Emanuele

  • http://etherealmind.com Greg Ferro

    Thanks fro the tip. I couldn’t make this work in my testing, but I will try it again next week.

    • Emanuele

      I’ve tested on a 2600Xm with c2600-advsecurityk9-mz.124-9.T1.bin, I rember when they introduced this feature…

      Have a nice weekend..
      Emanuele

      • Shakeelfarrukh

         Thank you man, finally i can use my router as terminal server.

  • http://www.globalconfig.net/ Brandon Carroll

    This is awesome. I pulled some docs on it yesterday and was going to upgrade the code on my 3640 to do it but didn’t have enough memory. Oh well, the memory is on order and the Material you put together is great! Thanks.
    Brandon

  • Pingback: IOS: Reverse SSH console access - Part 2 | My Etherealmind

  • Pingback: Changing the break character in Cisco IOS | My Etherealmind

  • http://www.askapache.com/ AskApache

    Sweet trick.. I was just reading about some updates CISCO released that add even more ssh functionality.. nice image..

  • Brindha

    Any idea whether Cisco 6500 boxes can be used as console servers or not ???

    • http://etherealmind.com Greg Ferro

      Not that I know of. There are no Async modules available.

  • Shakeelfarrukh

    Dear Sir, i am using 2621xm  me which d NM-16a but dont know how to configure it .
    kindly guide me which ios should i use and how how to configure it.

    when i am using  c2600-ipbase-12.3(22)
    and it gives me error when i give these commands
    line tty 1 16 or line 1 16
    (line 1 in not in async mode)

     

  • Pingback: Changing the break character in Cisco IOS — My Etherealmind

  • Arunmozhi G

    Hi Greg,
    Useful post.

    I have a Cisco 2921 connected to the console ports of different devices(servers,storage switches, N5ks etc. ). I have a loopback ip configured on the router and then I have configured the hosts on the router. So when I want to connect to the storage switch I will type the hostname and enter and it will connect me to that host. So, my question is, is there a way to connect to the console port of the devices straight away from outside using just one command with just the line number and how ?.

    Thanks
    Arun

  • http://twitter.com/IvanKalcho Ivan Kalcho

    Great post! I have one issue. I can establish ssh connection to the device and it prompts me for my password. I enter my password and it prompts me again for my password and at the end it says authentication failed. Any ideas?