How to Enable SSH on Cisco Switch, Router and ASA

by Ramesh Natarajan on August 22, 2013

Q: I have a Cisco switch in my network, which I can access by hooking up a console cable directly to the device. I like to access the switch remotely using SSH. How can I enable ssh on my Cisco 3750 Catalyst Switch?

A: By default, when you configure a Cisco device, you have to use the console cable and connect directly to the system to access it. Follow the steps mentioned below, which will enable SSH access to your Cisco devices. Once you enable SSH, you can access it remotely using PuTTY or any other SSH client.

1. Setup Management IP

First, make sure you have performed basic network configurations on your switch. For example, assign default gateway, assign management ip-address, etc. If this is already done, skip to the next step.

In the following example, the management ip address is set as in the 101 VLAN. The default gateway points to the firewall, which is

# ip default-gateway

# interface vlan 101
(config-if)# ip address

2. Set hostname and domain-name

Next, make sure the switch has a hostname and domain-name set properly.

# config t
(config)# hostname myswitch
(config)# ip domain-name

3. Generate the RSA Keys

The switch or router should have RSA keys that it will use during the SSH process. So, generate these using crypto command as shown below.

myswitch(config)# crypto key generate rsa
 The name for the keys will be:
 Choose the size of the key modulus in the range of 360 to 2048 for your
   General Purpose Keys. Choosing a key modulus greater than 512 may take
   a few minutes.

How many bits in the modulus [512]: 1024
 % Generating 1024 bit RSA keys, keys will be non-exportable...[OK]

Also, if you are running on an older Cisco IOS image, it is highly recommended that you upgrade to latest Cisco IOS.

4. Setup the Line VTY configurations

Setup the following line vty configuration parameters, where input transport is set to SSH. Set the login to local, and password to 7.

# line vty 0 4
(config-line)# transport input ssh
(config-line)# login local
(config-line)# password 7
(config-line)# exit

If you have not set the console line yet, set it to the following values.

# line console 0
(config-line)# logging synchronous
(config-line)# login local

5. Create the username password

If you don’t have an username created already, do it as shown below.

myswitch# config t
Enter configuration commands, one per line.  End with CNTL/Z.
myswitch(config)# username ramesh password mypassword

Note: If you don’t have the enable password setup properly, do it now.

myswitch# enable secret myenablepassword

Make sure the password-encryption service is turned-on, which will encrypt the password, and when you do “sh run”, you’ll seee only the encrypted password and not clear-text password.

myswitch# service password-encryption

5. Verify SSH access

From the switch, if you do ‘sh ip ssh’, it will confirm that the SSH is enabled on this cisco device.

myswitch# sh ip ssh
SSH Enabled - version 1.99
Authentication timeout: 120 secs; Authentication retries: 3

After the above configurations, login from a remote machine to verify that you can ssh to this cisco switch.

In this example, is the management ip-address of the switch.

remote-machine# ssh
login as: ramesh
Using keyboard-interactive authentication.


If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

{ 12 comments… read them below or add one }

1 John August 22, 2013 at 12:29 pm

I’m using telnet to connect to my Cisco switch. Is telnet enabled by default? If yes, how should I disable that?

2 Kane August 23, 2013 at 5:54 am

To disable telnet:

myswitch#configure terminal
myswitch(config)#line VTY 0 15
myswitch(config-line)#Transport preferred ssh

This will allow only SSH connections to the device. Be sure to complete the above listed steps as well.

3 Selvam August 23, 2013 at 7:12 am

Very nice explanation! Thanks.

4 Biswajit August 23, 2013 at 8:34 am

Great post. Thanks !!!

5 Jalal Hajigholamali August 24, 2013 at 9:48 pm

Very nice and useful material…

6 Anon August 26, 2013 at 1:14 am

This is definitely not the way you do it on a Cisco ASA btw ;)

7 Pedram August 30, 2013 at 3:49 am

Anon, this is just my words coming out of your mouth ;-)

8 Kane August 30, 2013 at 11:38 am

Hey Anon & Pedram,

Why don’t you 2 enlighten us then.


9 ali January 16, 2014 at 5:22 am

very user full post, thanks for sharing it. BDY if you can also describe how to use telnet and ssh on line vty same it i will be gr8

10 prat March 28, 2014 at 6:28 am

very good explanation thanks!! a lot

11 Lossless October 16, 2014 at 10:17 am

Example ASA

username sshuser password sshpassword
crypto key generate rsa modulus 2048
ssh inside
ssh timeout 5
ssh version 2
aaa authentication ssh console LOCAL

12 John November 2, 2014 at 12:05 am

Hi is the RSA key ”” automatically chosen by the router when you key in the crypto command?

Leave a Comment

Previous post:

Next post: