Jeremy’s IT Lab lecture video:

Day 42 - SSH


Commands


SSH Info

Console Port Security

1. Login

You can configure a password on the console line of a Cisco IOS device by entering console line configuration mode and using a few commands:

  • line console 0
    • Enters the console line configuration mode. There’s only one single console line, that’s why we specified a value of ‘0’.
  • password PASSWORD
    • Assigns a password for the console line to be accessed.
  • login
    • Enables the login feature, which prompts the user to enter the console line’s password before they can access the Cisco CLI.

2. Login Local

The console line can also be configured to require users to login using one of the configured usernames and passwords on the device through these commands:

  • username USERNAME secret PASSWORD
    • Configures the username and password to be used when users log into the Cisco CLI.
  • line console 0
    • Enters the console line configuration mode. There’s only one single console line, that’s why we specified a value of ‘0’.
  • login local
    • Enables the login local feature, which prompts the user to enter a configured username and password before they can access the Cisco CLI.

Default login settings

  • By default, no password is needed access the Cisco CLI of a Cisco IOS device via the console port.

Login & Login Local

  • If both login and login local are enabled on the device at the same time, then the login local will take priority over the other setting and will be used for authentication.

Layer 2 Switch - Management IP

Layer 2 switches are not IP routing aware, as in they don’t perform packet routing and don’t build routing tables. In this situation, we cannot connect to the switch through Telnet/SSH and perform management configurations.

  • However, an IP address can be assigned onto a Switch Virtual Interface (SVI) to allow remote connections to the CLI of the switch. (Through Telnet/SSH)
  • To perform that, you’d have to create an SVI through the interface vlan NUMBER command, assign it an IP address and enable it through the no shutdown command.
  • Then, you configure the switch’s default gateway to a router in its LAN through the ip default-gateway IP-ADDRESS command.

The Importance of a Switch's Default Gateway

  • If the switch doesn’t have a default gateway to a router in its LAN, it cannot communicate with PCs which are outside of its LAN, therefore, Telnet/SSH communications cannot be made.

Telnet General Information

Teletype Network (Telnet) is an old protocol used to remotely access the CLI of a remote host.

  • Telnet servers listen on port 23.
  • It has been replaced by the more secure protocol ‘SSH’, due to Telnet’s lack of security which sends data in plain text with no encryption.

Telnet Configuration - VTY Lines

  • enable secret PASSWORD
    • Configures a password to access privileged exec mode.
    • Required for Telnet to function, as you won’t be able to access privileged exec mode without a password.
  • username USERNAME secret PASSWORD
    • Configures a username and password which are used for the login local feature.
  • access-list ACL-ID { permit | deny } SOURCE
    • Initializes an ACL which could be used to restrict connections on the Cisco device, for example.
  • line vty 0 15
    • Enters Virtual Teletype configuration mode, which allows you to edit various aspects of the connection settings.
    • It is recommended to edit all VTY lines for all of them to have the same configurations.
  • login local
    • Enables the login local feature, which prompts the user to enter a configured username and password before they can access the Cisco CLI.
  • exec-timeout MINUTES SECONDS
    • Configures a timeout timer, which logs out the user after a specified period of inactivity.
  • transport input telnet
    • Changes the protocols which are allowed to make connections to the device.
    • In this case, only Telnet connections are allowed.
  • access-class ACL-ID in
    • Applies the ACL to the VTY lines.

Telnet Connection Command

To connect to a Telnet server through a PC for example, you’d need to use this command:

telnet IP-ADDRESS


Secure Shell (SSH) General Information

Secure Shell (SSH) is a shell connection protocol that was developed to replace less secure protocols like Telnet.

  • SSH servers listen on port 22.
  • It provides security features such as data encryption and authentication.
  • There are two SSH versions:
    1. SSHv1
    2. SSHv2
  • If a device supports both version 1 and version 2, it is said to run version 1.99.

1. SSH Configuration - Check SSH Support

There are Cisco devices which support SSH and others that don’t.

  • IOS images that support SSH will have ‘K9’ in their name.
  • Cisco also has NPE (No Payload Encryption) IOS images which are sent to countries that have restrictions on encryption technologies.
    • NPE IOS images do not support cryptographic features such as SSH.

Command to Check SSH Support

You can check if a Cisco IOS image supports SSH or not through this command:

  • show version
    • Shows information about the current device’s version and OS.

2. SSH Configuration - RSA Keys

For SSH to be enabled and used, an RSA public and private key pair must be generated on the device. The RSA keys are used for encryption/decryption, authentication, and etc.

  • There are two necessary conditions that must be met before RSA key generation is allowed on the device:
    1. The device must have a unique hostname (not the default hostname like ‘Router’)
    2. The device must have a DNS domain name set up through the ip domain name DOMAIN-NAME command. (Also known as a Fully Qualified Domain Name [FQDN])
  • When these two conditions are met, you can use the crypto key generate rsa command in order to generate RSA keys on the current device.
    • A modulus size must be inputted afterwards.
    • The minimum modulus size is 768 bits for SSHv2.

3. SSH Configuration - VTY Lines

  • enable secret PASSWORD
    • Configures a password to access privileged exec mode.
  • username USERNAME secret PASSWORD
    • Configures a username and password which are used for the login local feature.
  • access-list ACL-ID { permit | deny } SOURCE
    • Initializes an ACL which could be used to restrict connections on the Cisco device, for example.
  • ip ssh version 2
    • Sets the SSH version to version 2
    • Optional, but recommended
  • line vty 0 15
    • Enters Virtual Teletype configuration mode, which allows you to edit various aspects of the connection settings.
    • It is recommended to edit all VTY lines for all of them to have the same configurations.
  • login local
    • Enables the login local feature, which prompts the user to enter a configured username and password before they can access the Cisco CLI.
  • exec-timeout MINUTES SECONDS
    • Configures a timeout timer, which logs out the user after a specified period of inactivity.
  • transport input ssh
    • Changes the protocols which are allowed to make connections to the device.
    • In this case, only SSH connections are allowed.
  • access-class ACL-ID in
    • Applies the ACL to the VTY lines.

SSH Connection Commands

To connect to an SSH server through a PC for example, you’d need to use either of these commands:

  1. ssh -l USERNAME IP-ADDRESS
  2. ssh USERNAME@IP-ADDRESS

Summarized Steps For SSH Configuration

For SSH to be working optimally and configured properly, you have to complete the following steps:

  1. Configure a unique hostname
  2. Configure a DNS domain name
  3. Generate RSA key pairs
  4. Configure an ‘enable’ password
  5. Configure a username and password along with login local
  6. Enable SSHv2 (only) through the ip ssh version 2 command
  7. Configure VTY lines

Jeremy’s IT Lab előadásvideó:

42. Nap - SSH


Parancsok


SSH Információk

Konzolport Biztonság (Console Port Security)

1. Login

Egy Cisco IOS eszköz konzolvonalára (console line) jelszó állítható be a vonal konfigurációs módjába lépve a következő parancsokkal:

  • line console 0
    • Belép a konzolvonal konfigurációs módjába. Mivel csak egyetlen konzolport van, az azonosító értéke mindig '0'.
  • password PASSWORD
    • Jelszót rendel a konzolvonal eléréséhez.
  • login
    • Bekapcsolja a login funkciót, amely a konzol jelszavának megadására kötelezi a felhasználót a CLI elérése előtt.

2. Login Local

A konzolvonal beállítható úgy is, hogy a helyileg létrehozott felhasználónév és jelszó párosok valamelyikével lehessen csak belépni:

  • username USERNAME secret PASSWORD
    • Létrehoz egy felhasználónevet és titkosított jelszót a helyi felhasználói adatbázisban.
  • line console 0
    • Belép a konzolvonal konfigurációs módjába.
  • login local
    • Bekapcsolja a login local funkciót, amely a helyi adatbázisban lévő felhasználónév és jelszó megadását követeli meg a CLI eléréséhez.

Alapértelmezett bejelentkezési beállítások

  • Alapértelmezés szerint nem szükséges jelszó a Cisco IOS eszköz konzolportján keresztüli eléréséhez.

Login & Login Local

  • Ha a login és a login local parancsok egyszerre vannak konfigurálva az eszközön, a login local elsőbbséget élvez, és a rendszer a helyi felhasználói adatbázist fogja használni a hitelesítéshez.

Layer 2 Switch - Menedzsment IP (Management IP)

A Layer 2 switchek nem végeznek IP útválasztást (routing), nem irányítanak csomagokat és nem építenek útválasztási táblát. Alapesetben IP cím nélkül nem érhetők el Telnet / SSH segítségével távoli felügyelet céljából.

  • Azonban hozzárendelhetünk egy IP címet egy Switch Virtual Interface-hez (SVI), amely lehetővé teszi a távoli CLI kapcsolatot a switchez (Telnet / SSH révén).
  • Ehhez hozzunk létre egy SVI-t az interface vlan NUMBER paranccsal, adjunk neki IP címet, majd kapcsoljuk be a no shutdown paranccsal.
  • Ezután konfiguráljuk a switch default gateway-ét a helyi LAN-ban lévő router IP címére az ip default-gateway IP-ADDRESS paranccsal.

A Switch Default Gateway-ének jelentősége

  • Ha a switch nem rendelkezik default gateway beállítással a helyi LAN routere felé, akkor nem tud kommunikálni a saját LAN-ján kívül eső gépekkel, így a más alhálózatokból indított Telnet / SSH kapcsolatok nem fognak felépülni.

Telnet Általános Információk

A Teletype Network (Telnet) egy régebbi protokoll távoli gépek és hálózati eszközök CLI felületének elérésére.

  • A Telnet szerverek a 23-as porton figyelnek.
  • Mára felváltotta a biztonságos SSH protokoll, mivel a Telnet minden adatot (beleértve a jelszavakat is) nyers szövegként (plain text), titkosítás nélkül továbbít a hálózaton.

Telnet Konfiguráció - VTY Vonalak

  • enable secret PASSWORD
    • Beállítja a priviliged exec mód eléréséhez szükséges jelszót.
    • Kötelező a Telnet működéséhez, mivel jelszó nélkül nem lehet belépni a privileged exec módba távoli kapcsolatról.
  • username USERNAME secret PASSWORD
    • Létrehoz egy felhasználói fiókot a login local hitelesítéshez.
  • access-list ACL-ID { permit | deny } SOURCE
    • Létrehoz egy ACL-t, amellyel korlátozható a bejelentkezésre jogosult IP címek köre.
  • line vty 0 15
    • Belép a Virtual Teletype (VTY) konfigurációs módba a távoli vonalak beállításához.
    • Ajánlott az összes VTY vonalat egyszerre konfigurálni az egységes beállítások biztosítására.
  • login local
  • exec-timeout MINUTES SECONDS
    • Beállítja az inaktivitási időkorlátot.
  • transport input telnet
    • Meghatározza a VTY vonalon engedélyezett kapcsolat típusát (itt csak Telnet engedélyezett).
  • access-class ACL-ID in
    • Alkalmazza az ACL-t a VTY vonalakra.

Telnet Kapcsolódási Parancs

Ha egy gépről Telnet szerverhez szeretnénk kapcsolódni:

telnet IP-ADDRESS


Secure Shell (SSH) Általános Információk

A Secure Shell (SSH) egy biztonságos hálózati protokoll távoli parancssori eléréshez, amelyet a nem biztonságos protokollok (mint a Telnet) leváltására terveztek.

  • Az SSH szerverek a 22-es porton figyelnek.
  • Erős titkosítást és megbízható hitelesítést nyújt.
  • Két fő verziója van:
    1. SSHv1 (elavult, sebezhető)
    2. SSHv2 (biztonságos, ajánlott)
  • Ha egy eszköz mind az 1-es, mind a 2-es verziót támogatja, a Cisco IOS a 1.99-es verziószámot jelzi ki.

1. SSH Konfiguráció - SSH Támogatás Ellenőrzése

Bizonyos régebbi vagy speciális Cisco rendszerek nem támogatják az SSH-t.

  • Az SSH-t támogató IOS lemezképek nevében megtalálható a 'K9' jelölés (kriptográfiai funkciók).
  • A Cisco forgalmaz NPE (No Payload Encryption) lemezképeket is olyan országok számára, ahol jogszabályi korlátozások vannak a titkosítási technológiákra.
    • Az NPE IOS lemezképek nem támogatnak kriptográfiai funkciókat, mint például az SSH.

Parancs az SSH Támogatás Ellenőrzésére

A Cisco IOS lemezkép verziója és SSH támogatása a következő paranccsal ellenőrizhető:

  • show version
    • Információkat jelenít meg az eszköz szoftververziójáról és hardveréről.

2. SSH Konfiguráció - RSA Kulcsok

Az SSH engedélyezéséhez és működéséhez egy RSA nyilvános és privát kulcspárt kell generálni az eszközön. Az RSA kulcsok felelnek a titkosításért és a munkamenet kulcscseréjéért.

  • Két kötelező előfeltételnek kell teljesülnie az RSA kulcsgenerálás előtt:
    1. Az eszköznek egyedi hostname-mel kell rendelkeznie (nem lehet az alapértelmezett, pl. 'Router')
    2. Be kell állítani egy DNS domain name-et az ip domain name DOMAIN-NAME paranccsal (létrehozva a FQDN nevet)
  • Ezen feltételek teljesülése után a crypto key generate rsa paranccsal generálható le az RSA kulcspár.
    • A parancs bekéri a kulcsméretet (modulus size).
    • Az SSHv2 használatához a minimális kulcsméret 768 bit (ajánlott az 1024 vagy 2048 bit).

3. SSH Konfiguráció - VTY Vonalak

  • enable secret PASSWORD
    • Beállítja a privileged exec mód jelszavát.
  • username USERNAME secret PASSWORD
    • Felhasználói fiókot hoz létre a login local hitelesítéshez.
  • access-list ACL-ID { permit | deny } SOURCE
    • Létrehozza a kapcsolatok korlátozására szolgáló ACL-t.
  • ip ssh version 2
    • Kizárólag az SSH 2-es verzióját engedélyezi (kizárja a nem biztonságos SSHv1-et).
    • Opcionális, de erősen ajánlott.
  • line vty 0 15
    • Belép a VTY vonalak konfigurációs módjába.
  • login local
    • Engedélyezi a helyi adatbázis alapú login local hitelesítést.
  • exec-timeout MINUTES SECONDS
    • Beállítja az inaktivitási időkorlátot.
  • transport input ssh
    • Kizárólag az SSH bejövő kapcsolatokat engedélyezi (letiltja a Telnetet).
  • access-class ACL-ID in
    • Alkalmazza az ACL-t a VTY vonalakra.

SSH Kapcsolódási Parancsok

SSH szerverhez kliensről való csatlakozáshoz használható parancsok:

  1. ssh -l USERNAME IP-ADDRESS
  2. ssh USERNAME@IP-ADDRESS

Az SSH Konfiguráció Összefoglaló Lépései

Az SSH optimális és biztonságos beállításához hajtsuk végre a következő lépéseket:

  1. Egyedi hostname beállítása
  2. DNS domain name beállítása
  3. RSA kulcspár generálása (crypto key generate rsa, min. 768 / 1024 bit)
  4. 'enable' jelszó beállítása (enable secret)
  5. Felhasználónév és titkos jelszó létrehozása (username ... secret ...) a login local hitelesítéshez
  6. SSHv2 kizárólagos engedélyezése az ip ssh version 2 paranccsal
  7. VTY vonalak konfigurálása (line vty 0 15, login local, transport input ssh)