How to Enable SSH on Cisco Routers and Switches
This post walks beginners through enabling SSH on Cisco routers and switches step by step. It covers hostname and domain name setup, RSA key generation, local user creation, VTY line configuration, and verification commands. SSH configuration maps directly to CCNA exam objective 4.8.
If you've been using Telnet to manage your Cisco devices, it's time to upgrade. Telnet sends everything in plaintext, including your passwords. SSH (Secure Shell) encrypts the entire session, making it the standard for remote device management. In this guide, you'll learn how to enable SSH on Cisco routers and switches step by step.
Why SSH Matters for the CCNA
SSH configuration appears directly in CCNA exam objective 4.8 under IP Services. Beyond the exam, every production network uses SSH for secure CLI access. Learning this now builds a habit you'll carry throughout your career.
Prerequisites Before You Configure SSH
Before you start, your device needs a few things in place:
- A hostname: The default "Router" or "Switch" hostname won't work. You need a unique hostname set.
- A domain name: Cisco uses the hostname and domain name together to generate the RSA encryption keys.
- An IP address on a management interface: You need a reachable interface to connect to (a loopback or a VLAN interface on a switch works well).
- Local user credentials or AAA: SSH requires authentication. The simplest method uses a local username and password.
Step-by-Step SSH Configuration
Step 1: Set the Hostname and Domain Name
Router(config)# hostname SW1
SW1(config)# ip domain-name anythingoverip.comStep 2: Generate RSA Encryption Keys
This is the step that actually enables SSH on the device. Cisco recommends a key size of at least 2048 bits. Anything under 768 bits will be rejected by modern SSH clients.
SW1(config)# crypto key generate rsa modulus 2048You'll see a message confirming the keys were generated. This also automatically enables SSH on the device.
Step 3: Create a Local User Account
SW1(config)# username admin privilege 15 secret Str0ngP@ss!Using secret instead of password stores the password as an MD5 hash rather than plaintext. Always use secret.
Step 4: Configure the VTY Lines for SSH
VTY lines are the virtual terminal lines used for remote access. You need to tell them to use SSH only and to authenticate using local credentials.
SW1(config)# line vty 0 15
SW1(config-line)# transport input ssh
SW1(config-line)# login localSetting transport input ssh blocks Telnet entirely on those lines. If you want to allow both during a transition period, you can use transport input ssh telnet, but the goal is SSH only.
Step 5: (Optional but Recommended) Set SSH Version 2
SW1(config)# ip ssh version 2SSHv1 has known vulnerabilities. Force version 2 on every device.
Verifying Your SSH Configuration
After configuring, verify everything is working with these commands:
SW1# show ip ssh
SSH Enabled - version 2.0
Authentication timeout: 120 secs; Authentication retries: 3
SW1# show ssh
%No SSHv1 server connections running.
%No SSHv2 server connections running.The show ip ssh command confirms SSH is enabled and shows the version. The show ssh command lists active SSH sessions. The output above reflects a device with no clients currently connected; once a client connects, you will see session details such as the connection ID, username, encryption cipher, and state.
Testing the Connection
From another Cisco device, test with:
Router# ssh -l admin 192.168.1.1From a Linux or Mac terminal, use:
ssh [email protected]If your connection succeeds and you're prompted for the password you created in Step 3, the configuration is working correctly.
Quick Troubleshooting Tips
- Connection refused: Check that RSA keys were generated and the VTY lines have
transport input sshconfigured. - Authentication failed: Confirm the username and secret are correct and that
login localis set on the VTY lines. - SSH version mismatch: Older clients may not support SSHv2. Try updating your SSH client.
What's Next
Now that your device is secured with SSH, the next logical step is understanding how network time is synchronized across your devices. In the next post, we'll cover NTP (Network Time Protocol) configuration, another key IP Services topic on the CCNA exam. Accurate timestamps matter more than you might think, especially when you're reading logs after an incident.
Tools and resources for this topic
- CCNA Official Cert Guide (Wendell Odom) — The definitive CCNA study resource. Both volumes cover the 200-301 exam blueprint in full.
- Wendell Odom CCNA Vol 1 — Covers networking fundamentals, switching, and routing basics.
- Wendell Odom CCNA Vol 2 — Covers advanced routing, WAN, infrastructure services, and security.