Hands-On Lab: Configuring SSH Access on a Router

This hands-on lab configures SSH for secure remote management on a router, generating an RSA key pair, requiring local authentication, and restricting VTY lines to SSH only, verifying Telnet access is completely disabled.

SSH ConfigurationRSA Key GenerationTransport Input SSH

~3 دقیقه مطالعه · آخرین به‌روزرسانی ۱ مهر ۱۴۰۵

Lab Objective

Configure a router to accept SSH connections for remote management, generate the required RSA key pair, configure local username-based authentication, and restrict the VTY lines to SSH only, verifying Telnet is no longer possible.

Lab Purpose

Telnet transmits all traffic, including passwords, in plaintext, making it trivially interceptable by anyone with access to the network path. SSH encrypts this traffic and should always be used instead in any production environment, discussed earlier in this series regarding device hardening.

Lab Topology

R1 ---- Gi0/0: 192.168.60.1/24

Management PC: 192.168.60.50/24

Task 1: Configure Basic Addressing

Configure R1's interface connecting to the management segment.

Task 2: Set the Hostname and Domain Name

Both are required before RSA key generation can succeed.

Task 3: Generate the RSA Key Pair

Generate a 2048-bit RSA key pair for SSH.

Task 4: Configure Local Authentication and SSH-Only VTY Access

Create a local username and password, then restrict VTY lines to SSH transport only.

Task 5: Verify SSH Access Works

Confirm the management PC can successfully connect via SSH.

Task 6: Verify Telnet Is Blocked

Confirm attempting to Telnet to R1 fails.

Solution and Verification

R1(config)# interface gigabitethernet0/0
R1(config-if)# ip address 192.168.60.1 255.255.255.0
R1(config-if)# no shutdown
R1(config-if)# exit

R1(config)# hostname R1
R1(config)# ip domain-name example.com

R1(config)# crypto key generate rsa

The name for the keys will be: R1.example.com
How many bits in the modulus [512]: 2048

% Generating 2048 bit RSA keys, keys will be
non-exportable...[OK]

R1(config)# username admin secret AdminSecure2026
R1(config)# line vty 0 15
R1(config-line)# login local
R1(config-line)# transport input ssh

ManagementPC (192.168.60.50)> ssh -l admin 192.168.60.1

Password:
R1>
-- Successful SSH connection

ManagementPC> telnet 192.168.60.1

Trying 192.168.60.1 ...
% Connection refused by remote host
-- Telnet is rejected outright, since
-- "transport input ssh" removed Telnet
-- from the list of permitted protocols
-- entirely, rather than merely deprioritizing it

Key Takeaway

Generating the RSA key pair requires both hostname and domain name to be configured first, since the key is associated with the device's fully qualified domain name — attempting crypto key generate rsa before setting both fails outright, a detail worth remembering when SSH configuration unexpectedly does not work on a freshly initialized device.

نوشته و پژوهش‌شده توسط دکتر شاهین صیامی

مقالات مرتبط

Hands-On Lab: Final Comprehensive CCNP Troubleshooting Challenge (BGP, DMVPN, and QoS Integration)

This hands-on lab presents a complex multi-layer failure across an integrated BGP-over-DMVPN topology combined with QoS marking, requiring systematic diagnosis of a route reflector misconfiguration, an NHRP registration failure, and an incorrectly applied QoS policy simultaneously affecting the same network.

ادامه

Hands-On Lab: Configuring BGP over DMVPN

This hands-on lab runs iBGP as the routing protocol across the same DMVPN hub-and-spoke topology used in the two previous labs, configuring the hub as a route reflector so spokes learn each other's routes without a full iBGP mesh, combining two previously separate concepts into one integrated design.

ادامه

Hands-On Lab: Configuring OSPF over DMVPN

This hands-on lab runs OSPF as the dynamic routing protocol across the same DMVPN hub-and-spoke topology, configuring the tunnel interface as an OSPF point-to-multipoint network type to correctly handle the hub-and-spoke adjacency pattern without requiring the broadcast network type's DR/BDR election.

ادامه

Hands-On Lab: Configuring EIGRP over DMVPN

This hands-on lab runs EIGRP as the dynamic routing protocol across the DMVPN hub-and-spoke topology built in earlier labs, verifying neighbor relationships form correctly across the multipoint tunnel and routes propagate without requiring per-spoke static configuration on the hub.

ادامه

Hands-On Lab: Configuring HSRP MD5 Authentication

This hands-on lab configures MD5 authentication on an HSRP group, verifying two routers with matching authentication strings form a normal active/standby relationship while a router with a mismatched string is excluded from the group entirely.

ادامه

Hands-On Lab: Configuring Cisco Umbrella-Style DNS Security via DNS Forwarding Redirection

This hands-on lab configures a router to redirect all client DNS queries toward a security-focused DNS resolver using DNS forwarding interception, approximating cloud-delivered DNS security enforcement without requiring per-client configuration changes.

ادامه