Seguridad y Redes

Tips, Video Tutoriales, Wifislax, VMware, Linux, GNS3, Eve-NG, CCNA, Cisco Routers, Switches

Este vídeo muestra como configurar SSH (Secure SHell) en un router, utilizando el simulador gráfico GNS3. En resumen, lo primero es configurarle un hostname al router y establecer un nombre de dominio. Estos detalles son necesarios para generar las claves rsa, una vez terminado de generar las claves, después solo toca configurar algunos detalles adicionales como el configurar el tiempo de inactividad para la sesión, el numero de veces que uno puede fallar al intentarse logearse, crear un nombre de usuario con su respectiva contraseña y también los protocolos permitidos para entrar por las lineas VTY. Por ultimo se realiza la prueba iniciando sesión SSH desde PuTTY.

Comandos
R1> enable
R1# configure terminal
R1(config)# int f0/0
R1(config-if)# ip address 192.168.1.1 255.255.255.0
R1(config-if)# no shut
R1(config-if)# end
R1# show ip int brief
R1# ping 192.168.1.2
R1# conf t
R1(config)# enable secret cisco
R1(config)# ip domain-name delfirosales.com
R1(config)# crypto key generate rsa general-keys modulus 1024
R1(config)# ip ssh time-out 60
R1(config)# ip ssh authentication-retries 3
R1(config)# line vty 0 4
R1(config-line)# login local
R1(config-line)# transport input ssh telnet
R1(config-line)# exit
R1(config)# username delfirosales password cisco
R1(config)# exit
R1# wr
Cliente SSH (PuTTY)
login as: delfirosales
Password: cisco
R1> enable
Password: cisco
R1# show ip int brief
R1# conf t
R1(config)# hostname delfirosales
delfirosales(config)# end
delfirosales# wr
Video Online
http://www.youtube.com/watch?v=YJIhk2gm2RA

GNS3 Lab: Configuración de SSH (Secure SHell) en GNS3

El primer paso es configurar la interface de bucle invertido con la dirección IP 192.168.1.2 y mascara de subred 255.255.255.0. Hecho lo anterior ahora agregamos un Router y una Nube (Interface de Bucle Invertido) en GNS3 y los conectamos con un cable FastEthernet. Iniciamos el Router (R1) dando clic derecho - "Inicio", una vez mas hacemos clic derecho para abrir la "consola" y ya que hallamos realizado estos pasos, el router comenzara a descomprimir el IOS.


Connected to Dynamips VM "R1" (ID 0, type c3725) - Console port
Smart Init is disabled. IOMEM set to: 5
                         Using iomem percentage: 5
Restricted Rights Legend

Use, duplication, or disclosure by the Government is
subject to restrictions as set forth in subparagraph
(c) of the Commercial Computer Software - Restricted
Rights clause at FAR sec. 52.227-19 and subparagraph
(c) (1) (ii) of the Rights in Technical Data and Computer
Software clause at DFARS sec. 252.227-7013.

cisco Systems, Inc.
170 West Tasman Drive
San Jose, California 95134-1706

Cisco IOS Software, 3700 Software (C3725-ADVENTERPRISEK9-M), Version 12.4(15)T5, RELEASE SOFTWARE (fc4)
Technical Support: https://www.cisco.com/techsupport
Copyright (c) 1986-2008 by Cisco Systems, Inc.
Compiled Wed 30-Apr-08 18:27 by prod_rel_team
Image text-base: 0x60008930, data-base: 0x6363A000

Use format command to format the card as DOS File System.
Or use erase command to format the card as Low End File System.

This product contains cryptographic features and is subject to United
States and local country laws governing import, export, transfer and
use. Delivery of Cisco cryptographic products does not imply
third-party authority to import, export, distribute or use encryption.
Importers, exporters, distributors and users are responsible for
compliance with U.S. and local country laws. By using this product you
agree to comply with applicable laws and regulations. If you are unable
to comply with U.S. and local laws, return this product immediately.

A summary of U.S. laws governing Cisco cryptographic products may be found at:
https://www.cisco.com/wwl/export/crypto/tool/stqrg.html

If you require further assistance please contact us by sending email to
export@cisco.com.

Cisco 3725 (R7000) processor (revision 0.1) with 124928K/6144K bytes of memory.
Processor board ID XXXXXXXXXXX
R7000 CPU at 240MHz, Implementation 39, Rev 2.1, 256KB L2, 512KB L3 Cache
2 FastEthernet interfaces
DRAM configuration is 64 bits wide with parity enabled.
55K bytes of NVRAM.
16384K bytes of ATA System CompactFlash (Read/Write)
Installed image archive

SETUP: new interface FastEthernet0/0 placed in "shutdown" state
SETUP: new interface FastEthernet0/1 placed in "shutdown" state

Press RETURN to get started!

echsupport
Copyright (c) 1986-2008 by Cisco Systems, Inc.
Compiled Wed 30-Apr-08 18:27 by prod_rel_team
*Mar  1 00:00:22.995: %SNMP-5-COLDSTART: SNMP agent on host R1 is undergoing a cold start
*Mar  1 00:00:23.319: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is OFF
*Mar  1 00:00:23.319: %CRYPTO-6-GDOI_ON_OFF: GDOI is OFF
R1>
Ya que el router se halla iniciado correctamente, le configuraremos una IP 192.168.1.1 con mascara de subred 255.255.255.0 y probamos la conectividad haciendo un ping a la interface loopback.
R1> en
R1# conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)# int f0/0
R1(config-if)# ip address 192.168.1.1 255.255.255.0
R1(config-if)# no shut
R1(config-if)# end
*Mar  1 00:00:56.195: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:00:57.195: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1# show ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.1.1     YES manual up                    up
FastEthernet0/1            unassigned      YES unset  administratively down down
R1#
R1# ping 192.168.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 20/58/92 ms
R1#
Ahora empezamos a configurar SSH, para esto primero tenemos que hacer, es crear un nombre de dominio.
R1# conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)# enable secret cisco
R1(config)# ip domain-name delfirosales.com
Generar el certificado RSA con un tamaño entre el rango de 360-2048. En este ejemplo se muestra con el tamaño de 1024.
R1(config)# crypto key generate rsa general-keys modulus 1024
The name for the keys will be: R1.delfirosales.com

% The key modulus size is 1024 bits
% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]

R1(config)#
*Mar  1 00:01:36.367: %SSH-5-ENABLED: SSH 1.99 has been enabled
Algunos detalles adicionales como el configurar el tiempo de inactividad para la sesión, el numero de veces que uno puede fallar al intentarse logearse.
R1(config)# ip ssh time-out ?
<1-120>  SSH time-out interval (secs)
R1(config)# ip ssh time-out 60
R1(config)# ip ssh authentication-retries 3
Configurar los protocolos permitidos en las lineas VTY.
R1(config)# line vty 0 4
R1(config-line)# login local
R1(config-line)# transport input ssh telnet
R1(config-line)# exit
R1(config)#
Crear un usuario y contraseña
R1(config)# username delfirosales password cisco
R1(config)# exit
R1# wr
Building configuration...
[OK]

Iniciamos sesion SSH con PuTTY

login as: delfirosales
Using keyboard-interactive authentication.
Password:

R1> enable
Password:
R1#
R1# show ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.1.1     YES manual up                    up
FastEthernet0/1            unassigned      YES unset  administratively down down
R1# conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)# hostname delfirosales
delfirosales(config)# end
delfirosales# wr
Building configuration...
[OK]

SSH funcionando en GNS3.

Configuración de SSH en un Router Cisco

SSH (Secure Shell) es mas seguro que Telnet, es por eso que en este post veremos como configurarlo en un Router Cisco. Lo primero que aremos es configurarle un hostname al router y establecer un nombre de dominio. Estos detalles son necesarios para generar las claves rsa y una vez terminado de generar las claves, solo tendremos que configurar algunas cosas adicionales, como crear un nombre de usuario con su respectiva contraseña, configurar el tiempo de inactividad para la sesión, el numero de veces que uno puede fallar al intentarse logearse y así como los protocolos permitidos para entrar por las lineas VTY.
R1# configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)# hostname Delfi
Delfi(config)# ip domain-name delfirosales.com  
Delfi(config)# crypto key generate rsa general-keys modulus ?
<360-2048>  size of the key modulus [360-2048]

Delfi(config)# crypto key generate rsa general-keys modulus 1024
The name for the keys will be: Delfi.delfirosales.com

% The key modulus size is 1024 bits
% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]
*Mar  1 00:03:52.355: %SSH-5-ENABLED: SSH 1.99 has been enabled

Delfi(config)# ip ssh time-out ?
<1-120>  SSH time-out interval (secs)

Delfi(config)# ip ssh time-out 60
Delfi(config)# ip ssh authentication-retries ?
<0-5>  Number of authentication retries

Delfi(config)# ip ssh authentication-retries 3
Delfi(config)# line vty 0 4
Delfi(config-line)# login local
Delfi(config-line)# transport input ssh telnet
Delfi(config-line)# exit
Delfi(config)# username delfirosales password cisco
Delfi(config)# exit
Utilizamos PuTTy para iniciar sesión en SSH, al conectarnos nos mostrado un dialogo para aceptar el certificado tal como se muestra en la siguiente imagen.

Una vez aceptado el certificado, iniciamos sesión con nuestro nombre de usuario y contraseña.