SSH and Telnet are both protocols for remote access, but there are differences between the two:
Security: SSH provides encrypted communication, while Telnet is insecure and sends data in clear text.
Port numbers: SSH uses port 22, Telnet uses port 23.
Functionality: SSH provides secure terminal emulation and also supports file transfers, while Telnet only provides terminal emulation.
Authentication: SSH uses public key and password-based authentication, Telnet only uses password-based authentication.
In general, SSH is preferred over Telnet for remote access due to its security and additional functionality
*Note for remote access to a router and an external device a default gateway must be configured
As an example here is the sample topology to be used in this exercise. First we must configure the router and the ssh keys. I have added in red some explanations that are not part of the command structure.
Router>enable
Router#configure terminal
Router(config)#interface gigabitEthernet 0/0/0
Router(config-if)#ip address 172.16.0.1 255.255.0.0 IP address of the router interface
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#hostname FOC1 changed the name of the router
FOC1(config)#ip domain name FOC added a domain name
FOC1(config)#crypto key generate rsa generate an ssh key using rsa
The name for the keys will be: FOC1.FOC
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 higher the number the more secure but longer to decrypt
% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]
FOC1(config)#enable password friend
*Mar 1 0:4:18.119: %SSH-5-ENABLED: SSH 1.99 has been enabled
FOC1(config)#username FOC password friends adding username and password
FOC1(config)#ip ssh version 2 ssh version
FOC1(config)#line vty 0 15 16 possible connections
FOC1(config-line)#transport input ssh type of connection ssh
FOC1(config-line)#login local local login
Expected results for testing from the PC in the topology. Make sure the PC has an IP address and default gateway configured