Ron and Ella Wiki Page

Extremely Serious

Page 15 of 33

Enable SSH on a Cisco Router

Pre-requisite

  • Putty application

Enabling SSH

  1. Connect to cisco console using putty.

  2. Press the enter key to enter into user mode.

  3. Execute the following command to enter into privilege mode:

    enable
  4. Load the startup-config into the running-config using the following command:

    copy startup-config running-config
  5. Execute the following command to enter into the configuration mode:

    config terminal
  6. Change the hostname using the following syntax:

    hostname 
  7. Change the domain name using the following syntax:

    ip domain-name 
  8. Generate the SSH keys using the following command:

    crypto key generate rsa general-keys
  9. On How many bits in the modules [512]:, type in 2048 and press the enter key.

  10. Enable SSH version 2 using the following command:

    ip ssh version 2
  11. Create an SSH credential using the following syntax:

    username  secret 
  12. Create 5 (i.e. vty 0 to 4) virtual terminals for SSH connections, using the following command.

    line vty 0 4
  13. Allow only SSH to the newly created virtual connection using the following command:

    transport input ssh
  14. Use only the local database for credentials using the following command:

    login local
  15. Exit the virtual terminal configuration:

    exit
  16. Exit the configuration mode:

    exit
  17. Save the update on the running-config to the startup-config file using the following command:

    copy running-config startup-config
  18. Using putty, connect on any known IP of the router via SSH using the credentials you made from step 11.

Simple Java Keystore Management

Importing a certificate to a keystore

keytool -importcert -alias <ALIAS> -v -keystore <KEYSTORE_FILE> -file <INPUT_FILE> -storepass <KEYSTORE_PASSWORD>

Listing the certificates from a keystore

keytool -list -v -keystore <KEYSTORE_FILE> -storepass <KEYSTORE_PASSWORD>

Include the -a <ALIAS> parameter to just display a single certificate

Delete a certificate from a keystore

keytool -delete -v -alias <ALIAS> -keystore <KEYSTORE_FILE> -storepass <KEYSTORE_PASSWORD>

Deleting an Entry from a Java Keystore

Use the following command to delete an entry of a Java keystore:

The keytool is normally found in $JAVA_HOME/jre/bin (i.e. the $JAVA_HOME variable is where you’ve installed JDK).

keytool -delete -v -alias <ALIAS> -keystore <KEYSTORE_FILE> -storepass <KEYSTORE_PASSWORD>
Token Description
ALIAS The alias used upon importing the certificate.
KEYSTORE_FILE The target key store file (e.g. cacerts found in $JAVA_HOME/jre/lib/security)
KEYSTORE_PASSWORD The password for accessing the keystore (i.e. the default is changeit)

Override the Forgotten Password on a Cisco Router

Pre-requisite

  • Putty application

Overriding the Forgotten Password

  1. Connect to cisco console using putty.

  2. Press the enter key to enter into user mode.

  3. Once in the user mode (i.e. the prompt with greater than sign >), reboot the cisco router (i.e. using the physical switch of the router).

  4. Going back to your putty terminal, once you see any text on it, issue the break command.

    1. Point and click your mouse to the putty icon on putty title bar.

    2. Select Special Command.

    3. Select Break.

      Expect the see the rom monitor prompt as follows:

      rommon 1 >

  5. Execute the following command to disable the startup-config:

    confreg 0x2142
  6. Reset cisco router using the following command:

    reset
  7. Expect to see the following question:

    Would you like to enter the initialization configuration dialog? [yes/no]
  8. Type in no for the answer and press the enter key.

  9. Press the enter key one more time to enter into user mode.

  10. Execute the following command to enter into privilege mode:

    enable
  11. Load the startup-config into the running-config using the following command:

    copy startup-config running-config
  12. On Destination filename [running-config]?, press the enter key.

  13. Execute the following command to enter into the configuration mode:

    config terminal
  14. Change the password using the following syntax:

    enable secret <PASSWORD>

    Example of setting cisco as the password:

    enable secret cisco
  15. Execute the following command to enable the startup-config:

    config-register 0x2102
  16. Exit from the configuration mode using the following command:

    exit
  17. Save the update on the running-config to the startup-config file using the following command:

    copy running-config startup-config
  18. On Destination filename [startup-config]?, press enter key.

  19. Reboot the cisco router (i.e. using the physical switch of the router).

    After this you have the new password in effect.

Using USB to Connect to Cisco Console

Pre-requisite

  • Windows 64-bit
  • Putty application

Connecting to Cisco Console

  1. Access https://software.cisco.com/download/home.

    This requires you to be logged in to download anything.

  2. Search for the following:

    Software on Chassis : 3945 Integrated Services Router
  3. On the Select a software type, choose the following:

    USB Console Software
  4. Download the latest release (i.e. 3.1 is the latest at the time of this writing).

    This is in the form of the zip file.

  5. Extract the zip file and select which appropriate installer (i.e. based on OS type) you need.

    We will choose Windows 64-bit for this procedure.

  6. Once the installer is identified, install it.

  7. Insert the mini USB-B to the console port at the back of the cisco router.

  8. Power on your cisco router.

  9. Insert the USB-A to one of your computer's USB where you installed the USB Console Software.

  10. Open your windows device manager and check the node, Ports (COM & LPT).

  11. Identify the COM port for Cisco Serial, as follows:

  12. Once the COM port is identified, open your putty application.

  13. Select Serial as the Connection type.

  14. In the Serial line, type in the identified COM port from step 11.

  15. Click the Open button.

    This will open a cisco console, if everything is good.

Using dos2unix

Sometimes we wrote a script intended for linux but we are using windows. However, when we deploy the script to linux it doesn't work.

For example you've created the file helloworld.sh in windows with the following content:

#!/bin/sh
echo "Hello World"

Transport helloworld.sh to linux and make it executable (i.e. using the command chmod 755 helloworld.sh). Execute it using the following command:

./helloworld.sh

Expect to see something similar to the following error:

-bash: ./helloworld.sh: /bin/sh^M: bad interpreter: No such file or directory

To remedy this, run dos2unix command with helloworld.sh as follows:

dos2unix helloworld.sh

Expect an output similar to the following:

dos2unix: converting file helloworld.sh to Unix format...

After this, execute the helloworld.sh again and expect no error.

Requesting for Certificate with certbot-auto

Requesting for certificate

certbot-auto certonly -m <EMAIL_NAME> --webroot -w <WEBROOT_PATH> -d <DOMAIN_NAMES>

Example

certbot-auto certonly -m admin@example.com --webroot -w /usr/share/nginx/www -d www.example.com

Expanding your certificates

certbot-auto certonly --webroot --agree-tos -w <WEBROOT_PATH> --expand -d <DOMAIN_NAMES>

Example

certbot-auto certonly --webroot --agree-tos -w /usr/share/nginx/blog --expand -d blog.example.com

Display information about certificates you have from Certbot

certbot-auto certificates

Installing Jenkins in Ubuntu

Requirement

  • Java 8 +

Installing Jenkins

  1. Install the jenkins key:
    wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
  2. Register the jenkins source:
    sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
  3. Add the universe repository:
    sudo add-apt-repository universe
  4. Update the repository:
    sudo apt-get update
  5. Install jenkins:
    sudo apt-get install jenkins -y

Preparing Jenkins

  1. Access jenkins:
    http://localhost:8080/
  2. Use the password found from the following file for Administrator Password:
    sudo less /var/lib/jenkins/secrets/initialAdminPassword
  3. In Getting Started page select:
    Install suggested plugins
  4. Create the first admin user.
  5. Provide the Jenkins URL in the Instance Configuration.
  6. Click the Start using Jenkins button.

Monitoring Artifactory Service with Nagios

Requirement

  • check_jmx plugin

Enable JMX on Artifactory

  1. Update the /var/opt/jfrog/artifactory/etc/default file to add the following:
    export JAVA_OPTIONS="$JAVA_OPTIONS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=5000 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"

    If you wanted to connect remotely (e.g. jconsole) add the following argument:

    -Djava.rmi.server.hostname=<IP_ADDRESS>
  2. Restart the artifactory service:
    sudo systemctl restart artifactory.service

Testing with check_jmx plugin

/usr/local/nagios/libexec/check_jmx/nagios/plugin/check_jmx -U service:jmx:rmi:///jndi/rmi://localhost:5000/jmxrmi -O "org.jfrog.artifactory:instance=Artifactory, type=Storage,prop=Binary Storage" -A Size

Expect to see something similar to the following output:

JMX OK Size=377653571

Related Post
Downloading the Nagios check_jmx Plugin in Ubuntu

Downloading the Nagios check_url.pl Plugin in Ubuntu

Downloading the check_url.pl plugin

  1. Change to the nagios plugin directory:
    cd /usr/local/nagios/libexec/
  2. Download the check_url.pl plugin:
    sudo wget -O check_url.pl "https://exchange.nagios.org/components/com_mtree/attachment.php?link_id=1395&cf_id=24"
  3. Make the plugin executable:
    sudo chmod 755 check_url.pl
  4. Update the file check_url.pl to replace all tmp_ with /tmp/tmp_ text (i.e. if you are using vi for editing using the following:)
    %s#tmp_#/tmp/tmp_#g

Testing The Plugin

/usr/local/nagios/libexec/check_url.pl https://www.google.com

Expect to see the following output:

OK: 200  OK

Displaying the Help

/usr/local/nagios/libexec/check_url.pl -h
« Older posts Newer posts »