Jeremy’s IT Lab lecture video:
Commands
Commands List
SSH Show Commands
16. SSH
Link to original
- show ip ssh
-->Shows detailed information about the current SSH configurationSSH Global & Line Configuration Commands
SSH / Line Configuration
1. General
- ip ssh version version { 1 | 2 }
-->Sets the SSH version- ip default-gateway ip-address
-->Configures the switch’s default gateway- exec-timeout minutes seconds
-->Sets a timeout timer that will log out the user from the current session after a specified period of inactivity- crypto key generate rsa
-->Generates a RSA keys to be used for SSH authentication (requires a Domain Name)- show version
-->Shows information about the current device’s version and OS2. Console Line Configuration
- line console 0
-->Enters console line configuration mode- password password
-->Sets a password on the console line- login
-->Enables login when connecting through the console line/port, which prompts the user to enter a password only, in order to access the Cisco IOS CLI- login local
-->Enables local login when connecting through the console line/port, which prompts the user to enter a username and password in order to access the Cisco IOS CLI (used with Pass command)3. VTY Line Configuration
Link to original
- line vty line-number
ORlow-line-number high-line-number-->Enters VTY line configuration mode. You can specify either one line to be configured (Ex. 0) or a range of lines (Ex. 0 15)- login
-->Enables login when connecting through the VTY line(s), which prompts the user to enter a password only, in order to access the Cisco IOS CLI- login local
-->Enables local login when connecting through the VTY line(s), which prompts the user to enter a username and password in order to access the Cisco IOS CLI (used with Pass command)- transport input connection-types { all | none | protocol(s) }
-->Allows the specified connection type(s) to connect through the VTY line(s) (SSH, Telnet, etc.)- access-class acl-id in
-->Applies an ACL inbound on the VTY line(s)
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
loginandlogin localare enabled on the device at the same time, then thelogin localwill 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 NUMBERcommand, assign it an IP address and enable it through theno shutdowncommand. - Then, you configure the switch’s default gateway to a router in its LAN through the
ip default-gateway IP-ADDRESScommand.
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:
- SSHv1
- 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:
- The device must have a unique hostname (not the default hostname like ‘Router’)
- The device must have a DNS domain name set up through the
ip domain name DOMAIN-NAMEcommand. (Also known as a Fully Qualified Domain Name [FQDN])
- When these two conditions are met, you can use the
crypto key generate rsacommand 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:
ssh -l USERNAME IP-ADDRESSssh USERNAME@IP-ADDRESS
Summarized Steps For SSH Configuration
For SSH to be working optimally and configured properly, you have to complete the following steps:
- Configure a unique hostname
- Configure a DNS domain name
- Generate RSA key pairs
- Configure an ‘enable’ password
- Configure a username and password along with
login local - Enable SSHv2 (only) through the
ip ssh version 2command - Configure VTY lines
Jeremy’s IT Lab előadásvideó:
Parancsok
Parancslista
SSH Show Parancsok
16. SSH
Eredeti hivatkozása
- show ip ssh
-->Részletes információkat jelenít meg a jelenlegi SSH konfigurációrólSSH Globális & Line Konfigurációs Parancsok
SSH / Line Konfiguráció
1. Általános
- ip ssh version version { 1 | 2 }
-->Beállítja az SSH verzióját- ip default-gateway ip-address
-->Beállítja a switch default gateway-ét- exec-timeout minutes seconds
-->Beállít egy inaktivitási időkorlátot, amely után a munkamenet automatikusan kijelentkezik- crypto key generate rsa
-->RSA kulcspárt generál az SSH hitelesítéshez (előfeltétele a Domain Name)- show version
-->Információkat jelenít meg az eszköz hardveréről, IOS verziójáról és licencéről2. Konzolvonal (Console Line) Konfiguráció
- line console 0
-->Belép a konzolvonal konfigurációs módjába- password password
-->Jelszót állít be a konzolvonalhoz- login
-->Engedélyezi a jelszókérést konzolos csatlakozáskor (csak egyszerű jelszót kér a CLI eléréséhez)- login local
-->Engedélyezi a helyi adatbázis alapú hitelesítést konzolos csatlakozáskor (felhasználónevet és jelszót kér a CLI eléréséhez, a username paranccsal megadottak szerint)3. VTY Vonal Konfiguráció
Eredeti hivatkozása
- line vty line-number
VAGYlow-line-number high-line-number-->Belép a VTY vonalak konfigurációs módjába (megadható egyetlen vonal, pl. 0, vagy egy tartomány, pl. 0 15)- login
-->Engedélyezi a jelszókérést VTY csatlakozáskor (csak jelszót kér)- login local
-->Engedélyezi a helyi adatbázis alapú hitelesítést VTY csatlakozáskor (felhasználónevet és jelszót kér)- transport input connection-types { all | none | protocol(s) }
-->Meghatározza a VTY vonalakon engedélyezett bejövő protokollokat (SSH, Telnet stb.)- access-class acl-id in
-->Bejövő irányú ACL-t alkalmaz a VTY vonalakra
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 alogin localparancsok egyszerre vannak konfigurálva az eszközön, alogin localelső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 NUMBERparanccsal, adjunk neki IP címet, majd kapcsoljuk be ano shutdownparanccsal. - 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-ADDRESSparanccsal.
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- Bekapcsolja a login local hitelesítést.
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:
- SSHv1 (elavult, sebezhető)
- 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:
- Az eszköznek egyedi hostname-mel kell rendelkeznie (nem lehet az alapértelmezett, pl. 'Router')
- Be kell állítani egy DNS domain name-et az
ip domain name DOMAIN-NAMEparanccsal (létrehozva a FQDN nevet)
- Ezen feltételek teljesülése után a
crypto key generate rsaparanccsal 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:
ssh -l USERNAME IP-ADDRESSssh 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:
- Egyedi hostname beállítása
- DNS domain name beállítása
- RSA kulcspár generálása (
crypto key generate rsa, min. 768 / 1024 bit) - 'enable' jelszó beállítása (
enable secret) - Felhasználónév és titkos jelszó létrehozása (
username ... secret ...) alogin localhitelesítéshez - SSHv2 kizárólagos engedélyezése az
ip ssh version 2paranccsal - VTY vonalak konfigurálása (
line vty 0 15,login local,transport input ssh)