How to configure ssh on a switch?


This tutorial is all about ssh configuration on switches. In this tutorial, we all learn about how to configure ssh on a switch. First of all, we will learn about ssh. ssh is used to remote login to a device PC server switch or router securely. Basically, in other words, we can say that ssh is a remote login program as well as telnet which provides you a remote access to a switch, PC, router and a server by which we can manage any device remotely. But ssh configuration is more secure than telnet configuration because telnet username and password are sent online in simple text form but in ssh configuration, it is encrypted and hence makes ssh more secure than telnet. So let’s start here how to configure ssh on a Cisco switch.

Also Read: How to configure telnet on Cisco switches?

Now we will take a lab in Cisco packet tracer to learn ssh configuration on a switch. In this lab, we will learn ssh configuration using a multilayer switch which will connect two PCs. follow these below-given steps and codes to configure ssh on a switch.

ssh configuration on switch

learn how to configure ssh on a switch in few simple steps


Switch#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#hostname rahul

rahul(config)#interface vlan 1

rahul(config-if)#ip address

rahul(config-if)#no shut


%LINK-5-CHANGED: Interface Vlan1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up


rahul(config)#line vty 0 5

rahul(config-line)#password technohelper24



Now follow these steps to configure ssh on a switch


rahul#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

rahul(config)#ip domain name deepika

rahul(config)#crypto key gene rsa

The name for the keys will be: rahul.deepika

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]

rahul(config)#ip ssh version 2

*Mar 1 0:17:2.27: %SSH-5-ENABLED: SSH 1.99 has been enabled

rahul(config)#line vty 0 5

rahul(config-line)#transport input ssh



Now your switch will be configured with ssh configuration. Now we assign IP addresses to both the PCs statically because a DHCP server is not taken in this lab. So we provide IP address manually to both the PCs after that we check that ssh is configured successfully on your switch or not by access your switch remotely from a PC which is taken in this lab by us.

Now we check ssh connection from any of your PC

Packet Tracer PC Command Line 1.0

PC>ssh -l admin




It means our ssh will be successfully configured on the switch.

Now if you want to change your ssh username from admin to something else then you can do it from entering in switch global configuration mode. Follow these given below change your username


rahul#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

rahul(config)#username omprakash secret himanshu

rahul(config)#line vty 0 5

rahul(config-line)#login local


Now by these codes, your new user will be created, Now you will be logged into your switch from anywhere by entering this username and password on the PC.

Now once again test it from any of your PC by logging through your newly created user 

PC>ssh -l omprakash



rahul>show arp

Protocol Address Age (min) Hardware Addr Type Interface

Internet – 000A.F3E3.D229 ARPA Vlan1

Internet 13 000D.BD36.C5B6 ARPA Vlan1


If you have any queries regarding this, simply comment below and keep attach for further updates from this blog.

Your thoughts?

This site uses Akismet to reduce spam. Learn how your comment data is processed.