SSH TO ROUTER

Secure Shell (SSH) is a protocol which provides a secure remote access connection to network devices.
Communication between the client and server is encrypted in both SSH version 1 and SSH version 2.
Implement SSH version 2 when possible because it uses a more enhanced security encryption algorithm.
This document discusses how to configure and debug SSH on Cisco routers or switches that run a version of
Cisco IOS® Software that supports SSH. This document contains more information on specific versions and
software images.


Components Used
The information in this document is based on Cisco IOS 3600 Software (C3640−IK9S−M), Release
12.2(2)T1.
SSH was introduced into these IOS platforms and images:
SSH Version 1.0 (SSH v1) server was introduced in some IOS platforms and images starting in Cisco
IOS Software Release 12.0.5.S.
·
SSH client was introduced in some IOS platforms and images starting in Cisco IOS Software Release
12.1.3.T.
·
SSH terminal−line access (also known as reverse−Telnet) was introduced in some IOS platforms and
images starting in Cisco IOS Software Release 12.2.2.T.
·
SSH Version 2.0 (SSH v2) support was introduced in some IOS platforms and images starting in
Cisco IOS Software Release 12.1(19)E.
·
Refer to How to Configure SSH on Catalyst Switches Running CatOS for information on SSH
support in the switches.
·
Refer to the Software Advisor ( registered customers only) for a complete list of feature sets supported in different
Cisco IOS Software releases and on different platforms.
The information presented in this document was created from devices in a specific lab environment. All of the
devices used in this document started with a cleared (default) configuration. If you are in a live network, make
sure that you understand the potential impact of any command before you use it.

Authentication Test without SSH
First test the authentication without SSH to make sure that authentication works with the router Carter before
you add SSH. Authentication can be with a local username and password or with an authentication,
authorization, and accounting (AAA) server that runs TACACS+ or RADIUS. (Authentication through the
line password is not possible with SSH.) This example shows local authentication, which lets you Telnet into
the router with username "cisco" and password "cisco."
!−−− The aaa new−model command causes the local username and password on the router
!−−− to be used in the absence of other AAA statements.
aaa new−model
username cisco password 0 cisco
line vty 0 4
transport input telnet
!−−− Instead of aaa new−model, you can use the login local command.
Authentication Test with SSH
In order to test authentication with SSH, you have to add to the previous statements in order to enable SSH on
Carter and test SSH from the PC and UNIX stations.
ip domain−name rtp.cisco.com
!−−− Generate an SSH key to be used with SSH.
cry key generate rsa
ip ssh time−out 60
ip ssh authentication−retries 2
At this point, the show cry key mypubkey rsa command must show the generated key. After you add the
SSH configuration, test your ability to access the router from the PC and UNIX station. If this does not work,
see the debug section of this document.
Optional Configuration Settings
Prevent Non−SSH Connections
If you want to prevent non−SSH connections, add the transport input ssh command under the lines to limit
the router to SSH connections only. Straight (non−SSH) Telnets are refused.
line vty 0 4
!−−− Prevent non−SSH Telnets.
transport input ssh
Test to make sure that non−SSH users cannot Telnet to the router Carter.
Set Up an IOS Router or Switch as SSH Client
There are four steps required to enable SSH support on an IOS router:
1. Configure the hostname command.
2. Configure the DNS domain.
3. Generate the SSH key to be used.
4. Enable SSH transport support for the virtual type terminal (vtys).
If you want to have one device act as an SSH client to the other, you can add SSH to a second device called
Reed. These devices are then in a client−server arrangement, where Carter acts as the server, and Reed acts as
the client. The IOS SSH client configuration on Reed is the same as required for the SSH server configuration
on Carter.
!−−− Step 1: Configure the hostname if you have not previously done so.
hostname carter
!−−− The aaa new−model command causes the local username and password on the router
!−−− to be used in the absence of other AAA statements.
aaa new−model
username cisco password 0 cisco
!−−− Step 2: Configure the DNS domain of the router.
ip domain−name rtp.cisco.com
!−−− Step 3: Generate an SSH key to be used with SSH.
cry key generate rsa
ip ssh time−out 60
ip ssh authentication−retries 2
!−−− Step 4: By default the vtys' transport is Telnet. In this case,
!−−− Telnet is disabled and only SSH is supported.
line vty 0 4
transport input SSH
!−−− Instead of aaa new−model, you can use the login local command.
Issue this command to SSH from the IOS SSH client (Reed) to the IOS SSH server (Carter) in order to test
this:
SSH v1:
ssh −l cisco −c 3des 10.13.1.99
·
SSH v2:
ssh −v 2 −c aes256−cbc −m hmac−sha1−160 −l cisco 10.31.1.99
·
Add SSH Terminal−Line Access
If you need outbound SSH terminal−line authentication, you can configure and test SSH for outbound reverse
Telnets through Carter, which acts as a comm server to Philly.
ip ssh port 2001 rotary 1
line 1 16
no exec
rotary 1
transport input ssh
exec−timeout 0 0
modem In Out
Stopbits 1
If Philly is attached to Carter's port 2, then you can configure SSH to Philly through Carter from Reed with
the help of this command:
SSH v1:
ssh −c 3des −p 2002 10.13.1.99
·
SSH v2:
ssh −v 2 −c aes256−cbc −m hmac−sha1−160 −p 2002 10.31.1.99
·
You can use this command from Solaris:
ssh −c 3des −p 2002 −x −v 10.13.1.99
Configure the SSH Version
Configure SSH v1:
carter (config)#ip ssh version 1
Configure SSH v2:
carter (config)#ip ssh version 2
Configure SSH v1 and v2:
carter (config)#no ip ssh version