Easy management access to network devices

Some time ago I had troubles with the backspace key while configuring a Brocade device.

It did not do anything. The problem is, that my terminal (Konsole) does not send "Ctrl-H", but the Brocade terminal expects it to delete a character before the cursor. To solve this problem, I have a small expect script, which intercepts the backspace key and sends the correct character to the device.

#!/usr/bin/expect
 
eval spawn -noecho $argv
 
interact {
 \177        {send "\010"}
 "\033\[3~"  {send "\177"}
}

This file is saved under /usr/local/bin/brocade-kbdfix and made executable.

As I'm lazy and want to have quick access to the devices I have to configure, I've created two scripts which helps me to connect
to the device with the correct method (telnet or ssh):

#!/bin/bash
brocade-kbdfix ssh $(basename $0)
#!/bin/bash
brocade-kbdfix telnet $(basename $0)

They are saved as /usr/local/bin/brocade-ssh and /usr/local/bin/brocade-telnet. Now comes the "magic": For every device I create a symlink with the name of the device pointing to the apropriate connection method. F.e.:

user@server:~ # ls -Alh /usr/local/bin/           
total 60M
lrwxrwxrwx 1 root   root       26 Jan 14 09:26 router1 -> /usr/local/bin/brocade-ssh
-rwxr-xr-x 1 root   root      174 Jan 14 09:24 brocade-kbdfix
-rwxr-xr-x 1 root   root       74 Jan 14 09:24 brocade-ssh
-rwxr-xr-x 1 root   root       77 Jan 14 09:27 brocade-telnet
lrwxrwxrwx 1 root   root       29 Jan 14 09:27 router2 -> /usr/local/bin/brocade-telnet
[...]

If /usr/local/bin/ is in your path, you can now just enter the name of the device and your connected to it, including the correct connection method and the keyboard fix (assuming you have a DNS or hosts entry, or even a .ssh/config).

Puppet

Here is an example how I manage the configuration above with a small Puppet manifest:

class router_tools {
 
    File {
        mode   => '0755',
        owner  => root,
        group  => root,
    }
 
    file {
        '/usr/local/bin/brocade-kbdfix':
            source => 'puppet:///modules/router_tools/brocade-kbdfix';
 
        '/usr/local/bin/brocade-ssh':
            source => 'puppet:///modules/router_tools/brocade-ssh';
 
        '/usr/local/bin/brocade-telnet':
            source => 'puppet:///modules/router_tools/brocade-telnet';
    }
 
    # create symlinks for router access
    file {
        '/usr/local/bin/router1':
            ensure => link,
            target => '/usr/local/bin/brocade-ssh';
 
        '/usr/local/bin/router2':
            ensure => link,
            target => '/usr/local/bin/brocade-telnet';
    }
 
}
You've successfully subscribed to Tobias Brunner aka tobru
Great! Next, complete checkout to get full access to all premium content.
Error! Could not sign up. invalid link.
Welcome back! You've successfully signed in.
Error! Could not sign in. Please try again.
Success! Your account is fully activated, you now have access to all content.
Error! Stripe checkout failed.
Success! Your billing info is updated.
Error! Billing info update failed.