storm icon indicating copy to clipboard operation
storm copied to clipboard

Added support for tags in ssh_config in the form of '@tag1 @tag2'.

Open groundnuty opened this issue 9 years ago • 2 comments

In order to better manage large numbers of hosts in ssh_config it would be beneficial be able to tag them with project names etc. Now in the 'Host' section of ssh_config one can add a line that starts with a "#" followed (without a spacebar) by a list of tags eg. #@tag1 @tag2.

  1. The storm list command now displays apart from [custom_options] also a [tags] section if flag '-t' is supplied.
  2. New storm list-tag <tag> command was added, that displays only Hosts tagged with specific tag, or all tags if no tag is supplied

The test of 'storm list' command was modified to cover this new functionality.

I did not touch the web interface since I do not use. Those changes do not interfere with it nor change the behaviour of the storm list (or any other command) if ssh_config does not contain lines in a form of #@tag1...

An example ssh/config like that:

    ### default for all ##
    Host *
         ForwardAgent no
         ForwardX11 no
         ForwardX11Trusted yes
         User nixcraft
         Port 22
         Protocol 2
         ServerAliveInterval 60
         ServerAliveCountMax 30
         LocalForward 3128 127.0.0.1:3128
         LocalForward 3129 127.0.0.1:3128

    ## override as per host ##
    Host server1
         #@private
         HostName server1.cyberciti.biz
         User nixcraft
         Port 4242
         IdentityFile /nfs/shared/users/nixcraft/keys/server1/id_rsa
         IdentityFile /tmp/x.rsa

    ## Home nas server ##
    Host nas01
         #@private
         HostName 192.168.1.100
         User root
         IdentityFile ~/.ssh/nas01.key

    ## Login AWS Cloud ##
    Host aws.apache
         #@projectx
         HostName 1.2.3.4
         User wwwdata
         IdentityFile ~/.ssh/aws.apache.key

    ## Login to internal lan server at 192.168.0.251 via our public uk office ssh based gateway using ##
    ## $ ssh uk.gw.lan ##
    Host uk.gw.lan uk.lan
         #@projectx @uk @gw
         HostName 192.168.0.251
         User nixcraft
         ProxyCommand  ssh [email protected] nc %h %p 2> /dev/null

    ## Our Us Proxy Server ##
    ## Forward all local port 3128 traffic to port 3128 on the remote vps1.cyberciti.biz server ##
    ## $ ssh -f -N  proxyus ##
    Host proxyus
        #@projectx
        HostName vps1.cyberciti.biz
        User breakfree
        IdentityFile ~/.ssh/vps1.cyberciti.biz.key
        LocalForward 3128 127.0.0.1:3128

Produces such output for the storm list -t command:

 Listing entries:

   (*) General options:
	  forwardx11: no
	  localforward: 3128 127.0.0.1:3128, 3129 127.0.0.1:3128
	  protocol: 2
	  user: nixcraft
	  forwardagent: no
	  forwardx11trusted: yes
	  serveralivecountmax: 30
	  serveraliveinterval: 60
	  port: 22
    aws.apache -> [email protected]:22
	[custom options] identityfile=~/.ssh/aws.apache.key
	[tags] @projectx

    nas01 -> [email protected]:22
	[custom options] identityfile=~/.ssh/nas01.key
	[tags] @private

    proxyus -> [email protected]:22
	[custom options] identityfile=~/.ssh/vps1.cyberciti.biz.key localforward=3128 127.0.0.1:3128
	[tags] @projectx

    server1 -> [email protected]:4242
	[custom options] identityfile=/nfs/shared/users/nixcraft/keys/server1/id_rsa,/tmp/x.rsa
	[tags] @private

    uk.gw.lan uk.lan -> [email protected]:22
	[custom options] proxycommand=ssh [email protected] nc %h %p 2> /dev/null
	[tags] @projectx, @uk, @gw

The storm list-tag projectx gw command returns:

 Listing entries for tag @projectx

    aws.apache -> [email protected]:22
	[custom options] identityfile=~/.ssh/aws.apache.key

    uk.gw.lan uk.lan -> [email protected]:22
	[custom options] proxycommand=ssh [email protected] nc %h %p 2> /dev/null

    proxyus -> [email protected]:22
	[custom options] identityfile=~/.ssh/vps1.cyberciti.biz.key localforward=3128 127.0.0.1:3128

Listing entries for tag @gw

    uk.gw.lan uk.lan -> [email protected]:22
	[custom options] proxycommand=ssh [email protected] nc %h %p 2> /dev/null8

groundnuty avatar Nov 24 '16 00:11 groundnuty

awesome.

@berkerpeksag can you find time to review this?

emre avatar Dec 07 '16 06:12 emre

any chance to become a collaborator to this project and integrate it myself? :)

groundnuty avatar Jul 07 '17 15:07 groundnuty