Category: Cisco

  • Fixing Weak SSH Ciphers On a Cisco ASAv

    Fixing Weak SSH Ciphers On a Cisco ASAv

    By default the Cisco ASAv has weak ssh config that many modern OS’s do not support.

    ssh admin@10.1.10.56
    Unable to negotiate with 10.1.10.56 port 22: no matching host key type found. Their offer: ssh-rsa
    

    This error is from the client side ssh client refusing to use any of the host key algorithms that are offered by the ASAv.

    To get around this you can try the following.

    ssh -o HostKeyAlgorithms=+ssh-rsa 
    -o PubkeyAcceptedAlgorithms=+ssh-rsa
    admin@10.1.10.56
    The authenticity of host '10.1.10.56 (10.1.10.56)' can't be established.
    RSA key fingerprint is SHA256:TIbF/exW4uqfmy/yf8JyxddX8DApYduK2NVXNHfRBXI.
    This key is not known by any other names.
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    Warning: Permanently added '10.1.10.56' (RSA) to the list of known hosts.
    ssh_dispatch_run_fatal: Connection to 10.1.10.56 port 22: error in libcrypto

    However as you can see from the above output there is another error. This error is also from the client side OS, as its enforcing its own crypto policy.

    One way around this is to enable legacy crypto on the OS side. Which you can do via the command below.

    sudo update-crypto-policies --set LEGACY
    

    However, this is a bad idea and can screw up a lot of other things on the client side. Rather than work around this we will fix.


    Fix SSH on the Cisco ASAv – Instead of Breaking my Workstation

    Cisco documents that starting in ASA 9.16(1), the ASAv added support for EDDSA and ECDSA SSH host keys, and the ASAv will prefer EDDSA → ECDSA → RSA if those keys exist.

    Given I’m on ASAv 9.20(4), I should be able to generate these keys and then connect with my normal ssh client settings. See commands below.

    enable
    configure terminal
    
    ! Generate an Ed25519 (EdDSA) host key (preferred)
    crypto key generate eddsa edwards-curve ed25519
    
    ! Also generate an ECDSA host key (good fallback)
    crypto key generate ecdsa elliptic-curve 256
    
    write memory
    

    Restarting SSH on the ASAv

    Now we need to restart SSH on the ASAv to switch the host key used by SSH. You will need to run these commands from the console.

    conf t
    no ssh 0.0.0.0 0.0.0.0 management
    ssh 0.0.0.0 0.0.0.0 management
    end

    Now we can verify that keys in use on the ASAv. Specifically we want to look at the EDDSA and ECDSA .

    # show crypto key mypubkey ecdsa
    # show crypto key mypubkey eddsa

    Now we can login normally via SSH from our Workstation

     ssh admin@10.1.10.56
    The authenticity of host '10.1.10.56 (10.1.10.56)' can't be established.
    ECDSA key fingerprint is SHA256:Z5+PHzIl6L9BvvdYl2bBrFGi2rlmefmuv0uc27UTBo4.
    This key is not known by any other names.
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    Warning: Permanently added '10.1.10.56' (ECDSA) to the list of known hosts.
    admin@10.1.10.56's password: 
    User admin logged in to ciscoasa
    Logins over the last 1 days: 1.  
    Failed logins since the last login: 0.  
    Type help or '?' for a list of available commands.
    ciscoasa> 
    

    Further Configuration for SSH on the ASAv

    I did find that after all my changes to SSH on the ASAv, I was still unable to ssh to the asav from several VMs (new RHEL10 build for example).

    ssh admin@10.1.10.56
    kex_exchange_identification: read: Connection reset by peer

    In order to get ssh to work from RHEL 10, I ran the commands below on the ASAv

    conf t
    ssh key-exchange group dh-group14-sha256
    ssh key-exchange group curve25519-sha256

    Details below as to why this was required.

    Command AddedWhy RHEL 10 liked it
    dh-group14-sha256This moves the hashing from SHA-1 to SHA-256. RHEL 10 requires SHA-256 or higher for the handshake to be considered “safe.”
    curve25519-sha256This is the preferred algorithm for modern OpenSSH. It is extremely fast and mathematically robust. Once the ASA offered this, RHEL 10 stopped looking for other options and just connected.

  • Upgrade Cisco Catalyst WS-C4500X IOS: Step-by-Step Guide

    Upgrade Cisco Catalyst WS-C4500X IOS: Step-by-Step Guide

    I recently picked up a Cisco Catalyst WS-C4500X for my homelab as I am in the process of moving to all 10GBe. Before I put the new switch into service I want to make sure that it is running the latest IOS image.

    I will be using a USB drive that has already been formatted as FAT32 (FAT16 is also acceptable). I have copied the .bin file to the usb drive.

    Plug the USB drive into the front of the switch. Enter enable mode and run dir on the usb drive as shown below.

    Switch>en
    Switch#dir usb0:
    Directory of usb0:/
    
       37  drwx       16384  Mar 22 2025 23:28:06 +00:00  .Trash-1000
       38  -rwx   195351416  Mar 18 2025 01:16:52 +00:00  cat4500e-universal.SPA.03.11.11.E.152-7.E11.bin
    
    31440846848 bytes total (31220072448 bytes free)
    

    Now we need to copy the image from the USB drive to the bootflash on the switch.

    Switch#copy usb0:cat4500e-universal.SPA.03.11.11.E.152-7.E11.bin bootflash:

    The file will take a bit to copy. Once the copy is complete you will be returned to the prompt.

    We now want to confirm that the file is in bootflash.

    Switch#show bootflash:

    Output below, cat4500e-universal.SPA.03.11.11.E.152-7.E11.bin is our new file. As you can see by the dates this switch has not been upgraded in a long while.

    Now we need to change the config-register

    Switch>en
    Password: 
    Switch#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Switch(config)#config-register 0x2102
    

    Now we clear out the contents of the bootflash

    Switch(config)# no boot system

    We must now save the running config in order to see the updated boot vars

    Switch#show boot
    BOOT variable =
    CONFIG_FILE variable does not exist
    BOOTLDR variable does not exist
    Configuration register is 0x2101 (will be 0x2102 at next reload)

    Now we configure the switch to boot the new IOS image.

    Switch(config)# boot system bootflash:cat4500e-universal.SPA.03.11.11.E.152-7.E11.bin

    Now exit config mode and save changes

    Switch(config)#exit
    Switch#copy running-config startup-config
    Destination filename [startup-config]? 
    Building configuration...
    Compressed configuration from 1491 bytes to 878 bytes[OK]

    Now we confirm our boot config

    Switch#show boot
    BOOT variable = bootflash:cat4500e-universalk9.SPA.03.11.11.E.152-7.E11.bin,12;
    CONFIG_FILE variable does not exist
    BOOTLDR variable does not exist
    Configuration register is 0x2101 (will be 0x2102 at next reload)
    

    Configuration register 0x2101 will boot the first boot image shown in the output of dir bootflash:

    Configuration register 0x2102 overrides this behavior and boots the image specified in “BOOT variable” output.


    Reference

    1. https://youtu.be/vaiSC8SzHEc?si=kHM5ak1W_89zHx_j
    2. https://www.cisco.com/c/en/us/support/docs/routers/10000-series-routers/50421-config-register-use.html
  • How to Reset Cisco Catalyst WS-C4500X to Factory Defaults

    How to Reset Cisco Catalyst WS-C4500X to Factory Defaults

    Need to reset your Cisco Catalyst 4500X  back to the factory default settings? Have you forgotten your password? Follow the steps below.

    Note: that I am assuming that you have already established a console connection to the switch using a Cisco serial cable (rollover cable).

    Interrupt the boot sequence with Ctrl-C within the first 5 seconds after power on. This will allow you to enter the “ROM” aka ROM Monitor.

    Configure the switch to boot-up without reading the configuration memory (NVRAM).

    You will then see the following options below. Select as shown.

    Clear the config as shown below

    Now boot the switch with the boot command

    Reference

    1. https://www.cisco.com/c/en/us/support/docs/switches/catalyst-4500-series-switches/116436-technote-product-00.html
    2. https://www.cisco.com/c/en/us/support/docs/switches/catalyst-4000-series-switches/21229-pswdrec-cat4000-supiii-21229.html
  • How to Connect to a Cisco Serial Port via Minicom

    How to Connect to a Cisco Serial Port via Minicom

    Prerequisites

    You will need the following. A RJ45 to RS232 (serial) roll-over cable. Shown below

      And a USB to RS232(DB9) adapter (below)

        Connect the RJ45 to the serial port on your Cisco switch. Connect the two Db9s and plug the usb port into your workstation.

        Your should see the adapter recognized as ttyUSB0. You can check this with the command below

        $ sudo dmesg | grep tty
        [692949.868426] usb 3-12: FTDI USB Serial Device converter now attached to ttyUSB0
        

        Install and Configure Minicom

        Next you will need need to install minicom. Since I am running Ubuntu, I will use apt. If using Centos/Fedora you will use dnf.

        $ sudo apt install minicom -y

        Then we need to configure minicom. Start by running the command below.

        $ sudo minicom -s

        Select “Serial Port Setup”

        Change the Following

        1. Serial Device : /dev/ttyUSB0
        2. Bps/Par/Bits : 9600 8N1
        Correct minicom config for Cisco

        Save your config and relaunch minicom.

      1. Cisco Catalyst: Configure a Trunk Port with a Native Vlan

        data_sheet_c78-530976-1

        This post will show you how to configure a trunk port with a native vlan. In this specific example I am configuring a range of ports, but the commands for an individual interface will be the same once you have entered the config for a particular port.

        First enter configuration mode

        s3560#conf terminal

        Now we configure the range of ports. Here we are configuring the range of ports to be a trunk, using dot1q encapsulation. We are allowing vlans 96-99, and vlan 101. We are also setting vlan101 to be the native vlan (no vlan tagging required).

        s3560(config)#interface range gigabitEthernet 0/13 - 24
        s3560(config-if-range)#description generic trunk ports
        s3560(config-if-range)#switchport trunk encapsulation dot1q
        s3560(config-if-range)#switchport mode trunk
        s3560(config-if-range)#switchport trunk native vlan 101
        s3560(config-if-range)switchport trunk allowed vlan 96-99,101

        Now we enable spanning-tree portfast.

        s3560(config-if-range)#spanning-tree portfast

        %Warning: portfast should only be enabled on ports connected to a single
        host. Connecting hubs, concentrators, switches, bridges, etc... to this
        interface when portfast is enabled, can cause temporary bridging loops.
        Use with CAUTION

        %Portfast will be configured in 13 interfaces due to the range command
        but will only have effect when the interfaces are in a non-trunking mode.

        Now we enable bpduguard.

        s3560(config-if-range)#spanning-tree bpduguard enable
        s3560(config-if-range)#end

        Save your config changes

        s3560#copy run start
        Destination filename [startup-config]?
        Building configuration...
        [OK]
        0 bytes copied in 1.443 secs (0 bytes/sec)
        s3560#

      2. Cisco Catalyst: Reset/Clear Port Config

        Cisco Catalyst: Reset/Clear Port Config

        This blog is specific to the CIsco Catalyst 3560, but should work with other Catalyst switches.

        Reset Port Config to Default for One Port

        Use the command below to clear the configuration on a port.

        s3560(config)#default interface gigabitEthernet 0/3
        Interface GigabitEthernet0/3 set to default configuration

        Use the command below to verify that the running config for the port has been reset to the default configuration.

        s3560#show running-config interface gigabitEthernet0/3
        Building configuration...

        Output below

        Current configuration : 36 bytes
        !
        interface GigabitEthernet0/3
        end

        Now write your changes to memory.

        s3560#copy run start
        Destination filename [startup-config]?
        Building configuration...
        [OK]
        0 bytes copied in 1.427 secs (0 bytes/sec)

        Reset Port Config to Default for a Range of Ports

        Below we are going to clear/delete the config from a range of ports

        s3560#conf terminal
        
        s3560(config)#default interface range gigabitEthernet 0/13 - 24

        Again, don’t forget to save your changes.

        s3560#conf terminal
        s3560#copy run start

         

      3. How to Reset Cisco Catalyst 3560 Back to Factory Defaults

        3560-2


        Need to reset your Cisco Catalyst 3560 back to the factory default settings? Have you forgotten your password? Well you have come to the right place.

        Note that I am assuming that you have already established a console connection to the switch using a Cisco serial cable (rollover cable).

        Here are the details of my 3560G in case you were wondering…

        s3560#show ver
        Cisco IOS Software, C3560 Software (C3560-IPSERVICESK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1)
        Technical Support: http://www.cisco.com/techsupport
        Copyright (c) 1986-2011 by Cisco Systems, Inc.
        Compiled Thu 21-Jul-11 01:44 by prod_rel_team

        First you need to power down the switch. Once the switch is powered off, hold down the mode button, and power the switch on. The switch will boot up and you should see the switch prompt as shown below.

        Connect-1

        Now type flash_init. Your output should be similar to what you see below

        switch: flash_init
        Initializing Flash…
        flashfs[0]: 547 files, 19 directories
        flashfs[0]: 0 orphaned files, 0 orphaned directories
        flashfs[0]: Total bytes: 32514048
        flashfs[0]: Bytes used: 15487488
        flashfs[0]: Bytes available: 17026560
        flashfs[0]: flashfs fsck took 11 seconds.
        …done Initializing Flash.

        Check out the contents of flash and locate config.text and vlan.dat (if it exists).

        switch: dir flash:
        Directory of flash:/
        
        2  -rwx  564       <date>               vlan.dat
        3  -rwx  1914      <date>               private-config.text
        5  drwx  192       <date>               c2960-lanbasek9-mz.122-58.SE2
        6  -rwx  3096      <date>               multiple-fs
        7  -rwx  2289      <date>               config.text

        Now delete the vlan.dat and config.text.

        switch: del flash:config.text
        Are you sure you want to delete "flash:config.text" (y/n)?y
        File "flash:config.text" deleted
        
        switch: del flash:vlan.dat
        Are you sure you want to delete "flash:vlan.dat" (y/n)?y
        File "flash:vlan.dat" deleted

        Note that you can also just rename the config.text and vlan.dat if you are not certain that you want to delete them.

        switch: rename flash:config.text flash:config.old

        Now type boot, to reboot the switch. Once the switch is rebooted you will see the System Configuration Dialog, and will have the opportunity “to enter the initial configuration dialog”.