Skip to content
This repository was archived by the owner on Dec 21, 2022. It is now read-only.

Conversation

@groundnuty
Copy link

@groundnuty groundnuty commented Nov 24, 2016

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 nixcraft@gateway.uk.cyberciti.biz 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 -> wwwdata@1.2.3.4:22
	[custom options] identityfile=~/.ssh/aws.apache.key
	[tags] @projectx

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

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

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

    uk.gw.lan uk.lan -> nixcraft@192.168.0.251:22
	[custom options] proxycommand=ssh nixcraft@gateway.uk.cyberciti.biz 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 -> wwwdata@1.2.3.4:22
	[custom options] identityfile=~/.ssh/aws.apache.key

    uk.gw.lan uk.lan -> nixcraft@192.168.0.251:22
	[custom options] proxycommand=ssh nixcraft@gateway.uk.cyberciti.biz nc %h %p 2> /dev/null

    proxyus -> breakfree@vps1.cyberciti.biz: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 -> nixcraft@192.168.0.251:22
	[custom options] proxycommand=ssh nixcraft@gateway.uk.cyberciti.biz nc %h %p 2> /dev/null8

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". The 'storm list' command now displays apart from [custom_options] also a [tags] section if flag '-t' is supplied. 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' was modified to test this new functionality.
…ll tags, those substrings will be matched against tags and hosts with those tags will be displayed
@emre
Copy link
Owner

emre commented Dec 7, 2016

awesome.

@berkerpeksag can you find time to review this?

@groundnuty
Copy link
Author

groundnuty commented Jul 7, 2017

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants