Cisco 9400 Generate Ssh Key
Contents
- Generate Ssh Key
- Generate Ssh Key Putty
- Cisco 9400 Generate Ssh Key Password
- Cisco 9400 Generate Ssh Key Linux
Introduction
Secure Shell (SSH) is a protocol which provides a secure remote access connection to network devices. Communication between the client and server is encrypted in both SSH version 1 and SSH version 2. Implement SSH version 2 when possible because it uses a more enhanced security encryption algorithm.
To connect to a Cisco device via a Serial session a few settings need to be confirmed. COM Port - (be sure the COM number is correct, if you are using a usb adapter it may not default to using COM1. It could be COM3 or 4, You'll need to confirm by looking in device manager) Data Bits - set to 8 Stop Bits - set to 1 Parity - set to None.
- Cisco IOS Enable Secret Type 5 Password Cracker. Javascript tool to convert Cisco type 5 encrypted passwords into plain text so that you can read them. This is done using client side javascript and no information is transmitted over the Internet or to IFM. Toggle navigation.
- Your comments are correct about the crypto key that is generated for SSH. But that is not what the original post was asking about. The original post is asking about: crypto pki trustpoint TP-self-signed. Crypto pki certificate chain TP-self-signed. These are not the crypto RSA keys used for SSH.
- Create an RSA keys: Ciscozine(config)#crypto key generate rsa label ciscozine-rsa modulus 2048 The name for the keys will be: ciscozine-rsa% The key modulus size is 2048 bits% Generating 2048 bit RSA keys, keys will be non-exportable.
This document discusses how to configure and debug SSH on Cisco routers or switches that run a version of Cisco IOS® Software that supports SSH. This document contains more information on specific versions and software images.
Prerequisites
Requirements
The Cisco IOS image used must be a k9(crypto) image in order to support SSH. For example c3750e-universalk9-tar.122-35.SE5.tar is a k9 (crypto) image.
Components Used
The information in this document is based on Cisco IOS 3600 Software (C3640-IK9S-M), Release 12.2(2)T1.
SSH was introduced into these Cisco IOS platforms and images:
SSH Version 1.0 (SSH v1) server was introduced in some Cisco IOS platforms and images that start in Cisco IOS Software Release 12.0.5.S.
SSH client was introduced in some Cisco IOS platforms and images starting in Cisco IOS Software Release 12.1.3.T.
SSH terminal-line access (also known as reverse-Telnet) was introduced in some Cisco IOS platforms and images starting in Cisco IOS Software Release 12.2.2.T.
SSH Version 2.0 (SSH v2) support was introduced in some Cisco IOS platforms and images starting in Cisco IOS Software Release 12.1(19)E.
Refer to How to Configure SSH on Catalyst Switches Running CatOS for more information on SSH support in the switches.
Refer to the Software Advisor (registered customers only) for a complete list of feature sets supported in different Cisco IOS Software releases and on different platforms.
The information presented in this document was created from devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If you are in a live network, make sure that you understand the potential impact of any command before you use it.
Conventions
Refer to Cisco Technical Tips Conventions for more information on document conventions.
SSH v1 vs. SSH v2
Use the Cisco Software Advisor (registered customers only) in order to help you find the version of code with appropriate support for either SSH v1 or SSH v2.
Network Diagram
Test Authentication
Authentication Test without SSH
First test the authentication without SSH to make sure that authentication works with the router Carter before you add SSH. Authentication can be with a local username and password or with an authentication, authorization, and accounting (AAA) server that runs TACACS+ or RADIUS. (Authentication through the line password is not possible with SSH.) This example shows local authentication, which lets you Telnet into the router with username 'cisco' and password 'cisco.'
Authentication Test with SSH
In order to test authentication with SSH, you have to add to the previous statements in order to enable SSH on Carter and test SSH from the PC and UNIX stations.
At this point, the show crypto key mypubkey rsa command must show the generated key. After you add the SSH configuration, test your ability to access the router from the PC and UNIX station. If this does not work, see the debug section of this document.
Optional Configuration Settings
Prevent Non-SSH Connections
If you want to prevent non-SSH connections, add the transport input ssh command under the lines to limit the router to SSH connections only. Straight (non-SSH) Telnets are refused.
Test to make sure that non-SSH users cannot Telnet to the router Carter.
Set Up an IOS Router or Switch as SSH Client
There are four steps required to enable SSH support on a Cisco IOS router:
Configure the hostname command.
Configure the DNS domain.
Generate the SSH key to be used.
Enable SSH transport support for the virtual type terminal (vtys).
If you want to have one device act as an SSH client to the other, you can add SSH to a second device called Reed. These devices are then in a client-server arrangement, where Carter acts as the server, and Reed acts as the client. The Cisco IOS SSH client configuration on Reed is the same as required for the SSH server configuration on Carter.
Issue this command to SSH from the Cisco IOS SSH client (Reed) to the Cisco IOS SSH server (Carter) in order to test this:
SSH v1:
SSH v2:
Setup an IOS Router as an SSH server that performs RSA based User Authentication
Complete these steps in order to configure the SSH server to perform RSA based authentication.
Specify the Host name.
Define a default domain name.
Generate RSA key pairs.
Configure SSH-RSA keys for user and server authentication.
Configure the SSH username.
Specify the RSA public key of the remote peer.
Specify the SSH key type and version. (optional)
Exit the current mode and return to privileged EXEC mode.
Note: Refer to Secure Shell Version 2 Support for more information.
Add SSH Terminal-Line Access
If you need outbound SSH terminal-line authentication, you can configure and test SSH for outbound reverse Telnets through Carter, which acts as a comm server to Philly.
If Philly is attached to Carter's port 2, then you can configure SSH to Philly through Carter from Reed with the help of this command:
SSH v1:
SSH v2:
You can use this command from Solaris:
Restrict SSH access to a subnet
You need to limit SSH connectivity to a specific subnetwork where all other SSH attempts from IPs outside the subnetwork should be dropped.
You can use these steps to accomplish the same:
Define an access-list that permits the traffic from that specific subnetwork.
Restrict access to the VTY line interface with an access-class.
This is an example configuration. In this example only SSH access to the 10.10.10.0 255.255.255.0 subnet is permitted, any other is denied access.
Note: The same procedure to lock down the SSH access is also applicable on switch platforms.
Generate Ssh Key
Configure the SSH Version
Configure SSH v1:
/key-generator-fo-free-pc.html. Configure SSH v2:
Configure SSH v1 and v2:
Note: You receive this error message when you use SSHv1:
Note: Cisco bug ID CSCsu51740 (registered customers only) is filed for this issue. Workaround is to configure SSHv2.
Variations on banner Command Output
The banner command output varies between the Telnet and different versions of SSH connections. This table illustrates how different banner command options work with various types of connections.
Banner Command Option | Telnet | SSH v1 only | SSH v1 and v2 | SSH v2 only |
---|---|---|---|---|
banner login | Displayed before logging into the device. | Not displayed. | Displayed before logging into the device. | Displayed before logging into the device. |
banner motd | Displayed before logging into the device. | Displayed after logging into the device. | Displayed after logging into the device. | Displayed after logging into the device. |
banner exec | Displayed after logging into the device. | Displayed after logging into the device. | Displayed after logging into the device. | Displayed after logging into the device. |
Unable to Display the Login Banner
SSH version 2 supports the login banner. The login banner is displayed if the SSH client sends the username when it initiates the SSH session with the Cisco router. For example, when the Secure Shell ssh client is used, the login banner is displayed. When the PuTTY ssh client is used, the login banner is not displayed. This is because Secure Shell sends the username by default and PuTTY does not send the username by default.
The Secure Shell client needs the username to initiate the connection to the SSH enabled device. The Connect button is not enabled if you do not enter the host name and username. This screenshot shows that the login banner is displayed when Secure Shell connects to the router. Then, the login banner password prompt displays.
The PuTTY client does not require the username to initiate the SSH connection to the router. This screenshot shows that the PuTTY client connects to the router and prompts for the username and password. It does not display the login banner.
This screen shot shows that the login banner is displayed when PuTTY is configured to send the username to the router.
debug and show Commands
Before you issue the debug commands described and illustrated here, refer to Important Information on Debug Commands. Certain show commands are supported by the Output Interpreter Tool (registered customers only) , which allows you to view an analysis of show command output.
debug ip sshâDisplays debug messages for SSH.
show sshâDisplays the status of SSH server connections.
show ip sshâDisplays the version and configuration data for SSH.
Version 1 Connection and no Version 2
Version 2 Connection and no Version 1
Version 1 and Version 2 Connections
Sample Debug Output
Router Debug
Note: Some of this good debug output is wrapped to multiple lines because of spatial considerations.
Server Debug
Note: This output was captured on a Solaris machine.
What can go Wrong
These sections have sample debug output from several incorrect configurations.
SSH From an SSH Client Not Compiled with Data Encryption Standard (DES)
Solaris Debug
Router Debug
Bad Password
Router Debug
SSH Client Sends Unsupported (Blowfish) Cipher
Router Debug
Geting the '%SSH-3-PRIVATEKEY: Unable to retrieve RSA private key for' Error
If you receive this error message, it may be caused due to any change in the domain name or host name. In order to resolve this, try these workarounds.
Zeroize the RSA keys and re-generate the keys.
If the previous workaround does not work, try these steps:
Zeroize all RSA keys.
Reload the device.
Create new labeled keys for SSH.
Cisco bug ID CSCsa83601 (registered customers only) has been filed to address this behaviour.
Troubleshooting Tips
If your SSH configuration commands are rejected as illegal commands, you have not successfully generated a RSA key pair for your router. Make sure you have specified a host name and domain. Then use the crypto key generate rsa command to generate an RSA key pair and enable the SSH server.
When you configure the RSA key pair, you might encounter these error messages:
No hostname specified
You must configure a host name for the router using the hostname global configuration command.
No domain specified
You must configure a host domain for the router using the ip domain-name global configuration command.
The number of allowable SSH connections is limited to the maximum number of vtys configured for the router. Each SSH connection uses a vty resource.
SSH uses either local security or the security protocol that is configured through AAA on your router for user authentication. When you configure AAA, you must ensure that the console is not running under AAA by applying a keyword in the global configuration mode to disable AAA on the console.
No SSH server connections running.
This output suggests that the SSH server is disabled or not enabled properly. If you have already configured SSH, it is recommended that you reconfigure the SSH server in the device. Complete these steps in order to reconfigure SSH server on the device.
Delete the RSA key pair. After the RSA key pair is deleted, the SSH server is automatically disabled.
Note: It is important to generate a key-pair with at least 768 as bit size when you enable SSH v2.
Caution: This command cannot be undone after you save your configuration, and after RSA keys have been deleted, you cannot use certificates or the CA or participate in certificate exchanges with other IP Security (IPSec) peers unless you reconfigure CA interoperability by regenerating RSA keys, getting the CA's certificate, and requesting your own certificate again.Refer to crypto key zeroize rsa - Cisco IOS Security Command Reference, Release 12.3 for more information on this command.
Reconfigure the hostname and domain name of the device.
Generate an RSA key pair for your router, which automatically enables SSH.
Refer to crypto key generate rsa - Cisco IOS Security Command Reference, Release 12.3 for more information on the usage of this command.
Note: You can receive the SSH2 0: Unexpected mesg type received error message due to a packet received that is not understandable by the router. Increase the key length while you generate rsa keys for ssh in order to resolve this issue.
Configure SSH server. In order to enable and configure a Cisco router/switch for SSH server, you can configure SSH parameters. If you do not configure SSH parameters, the default values are used.
ip ssh {[timeout seconds] [authentication-retries integer]}Refer to ip ssh - Cisco IOS Security Command Reference, Release 12.3 for more information on the usage of this command.
Related Information
Assuming you have access to the physical switch, this guide will walk you through the steps required to reset a Cisco Switch back to factory default. This was most useful to me when I was purchasing random equipment off the internet to build a home lab. When I got the devices, they still had the owners config and I was stuck with no passwords..
11 Steps total
Step 1: Connect the console cable to your PC
The first step is to connect a console cable to the COM port of your workstation to gain access to the switch. If your workstation doesn't have a COM port, you'll need a Serial to USB adapter as seen below.
Serial To USB Adapter
http://www.newegg.com/Product/Product.aspx?Item=N82E16812156003
Step 2: Verify that it is a console cable
Below is a link to a standard Cisco console cable & attached is a picture to reference if you want to make sure you've got the right cable.
http://www.newegg.com/Product/Product.aspx?Item=N82E16833993038
Step 3: Download Putty and Start a Serial Connection
There are several software products that will allow you to do this, but I recommend using Putty. It is the most accepted and easiest to use in my opinion.
To gain access to the console launch Putty and select the Serial radius button.
Download Putty Here
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Step 4: Double Check Serial Settings
To connect to a Cisco device via a Serial session a few settings need to be confirmed.
COM Port - (be sure the COM number is correct, if you are using a usb adapter it may not default to using COM1. It could be COM3 or 4, You'll need to confirm by looking in device manager)
Data Bits - set to 8
Stop Bits - set to 1
Parity - set to None
Flow Control - set to None
Once the settings are confirmed click Open, which starts the session.
Step 5: Plug in the Console cable
Now with the terminal windows open, plug the console cable into the console port of the switch typically located on the back and labeled console.
Step 6: Hold the mode button on the from of the switch
Before powering on the switch hold the mode button located at the front of the switch on the left side.
Step 7: Power on the switch
Cisco Switches do not have an onoff switch, they are simply powered on by supplying power to them. At this now while still holding the mode button down, plug in the power cable.
Step 8: Release mode button once it boots
Once characters are displayed on the screen release the mode button.
Step 9: Press ctrl + pausebreak on the keyboard
While the boot process is in order hit ctrl+pausebreak on your keyboard. If you are using a laptop may need to use a usb keyboard to hit these keys.
Step 10: Enter the following commands
Switch: flash_init
Switch:dir flash:
Switch:flash:config.text flash:config.backup
Switch:boot
Step 11: Rename Configuration files & Remove passwords
Would you like to enter the inital configuration dialog? no
Switch > enable
SW1#renameflash:config.backup config.text
SW1#copy flash:config.text system:running-config
SW1#config terminal
SW1(config)#no enable secret.
SW1(config)#exit
SW1(config)#wr
You now have gained access to the switch and successfully returned it to factory default. You may also want to delete the vlan .dat file as it is not removed in the process of deleting the start up or running config.
Deleting Vlan.dat blog post
http://ccnanotebook.blogspot.com/2013/06/erase-vlan-data-cisco-switches.html
References
Generate Ssh Key Putty
- CCNA Notebook
Cisco 9400 Generate Ssh Key Password
9 Comments
Cisco 9400 Generate Ssh Key Linux
- MaceChamele0n Aug 19, 2013 at 08:47pm
Nice little write-up Duffney, quick and simple. Good Job.
- HabaneroDuffney Aug 19, 2013 at 09:20pm
Appreciate the review. :) I had to combine about 5 articles when I did it so I thought I could save others the pain of some Google Searching.
- Ghost ChiliNick42 Aug 20, 2013 at 12:23am
Nice write up, with graphics! But where are the instructions for BUILDING the console cable? ;)
- HabaneroDuffney Aug 20, 2013 at 02:35am
Not a bad Idea for another how-to. :) Watched my co worker make one for a baytech the other day.
- SonoraCaleb85 Sep 9, 2015 at 02:44pm
For step 10 this is more helpful ' switch: rename flash:config.text flash:config.text.old '
- AnaheimChris Strong Apr 1, 2016 at 07:55pm
Thank you for this kind sir! Helped me out tremendously
- Pimientoparampandey Sep 13, 2016 at 11:37am
Its very help full topic in networking industries. please send some imp topic name me for interview preparation.
itparampandey@gmail.com - SonoraTurd_Ferguson Mar 10, 2017 at 02:25am
Step 10 did not work for me on my Cisco 3560-X. I had to type the following:
Switch: ren flash:config.text flash:config.backupGreat write up. Thanks!
- Pimientolux209 Jun 2, 2017 at 10:05am
thanks ! very good guide, it helped me today to recover from a wrong radius config !