Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty gateway directories being created in current working directory #124

Closed
stk0vrfl0w opened this issue Mar 3, 2016 · 5 comments
Closed
Assignees
Milestone

Comments

@stk0vrfl0w
Copy link
Contributor

When trying to access a machine that uses a gateway, assh always creates an empty directory named after each of the gateways it had tried in the current working directory.

So, for the example assh.yml config file below, if I try to ssh to frankbastion and it goes through gateway3, there will be empty directories called gateway1, gateway2 and gateway3 created in the current working directory. Is there an option to disable directory creation? It's not necessary for my use case and pollutes my working spaces everywhere.

    defaults:
        LogLevel: error
        ForwardAgent: yes
        ServerAliveInterval: 30
        StrictHostKeyChecking: no
        UserKnownHostsFile: /dev/null

    hosts:

        gateway*:
            Hostname: "%h.mycompany.io"
            Inherits:
                - control-template

        frankbastion:
            DynamicForward: 5555
            Hostname: frank.mycompany.io
            Inherits:
                - gw-proxy

        beansbastion:
            DynamicForward: 6666
            Hostname: beans.mycompany.io
            Inherits:
                - gw-proxy


    templates:

        control-template:
            ControlMaster: auto
            ControlPath: ~/.ssh/%h_control.sock

        gw-proxy:
            ProxyCommand: nc -q0 %h 22
            Gateways:
                - gateway1
                - gateway2
                - gateway3
@moul moul self-assigned this Mar 3, 2016
@moul
Copy link
Owner

moul commented Mar 3, 2016

Hi @stk0vrfl0w, thank you for your feedback !

I will add an option to disable this feature


For now I suggest you to move your control path in a dedicated directory, i.e: ~/.ssh/sockets/%h_control.sock (mine is ControlPath: ~/.ssh/cm/%h-%p-%r.sock)

This way all the empty directories and .sock files are only polluting a subdirectory

@stk0vrfl0w
Copy link
Contributor Author

Thanks for the reply @moul . However, I'm fairly certain that the dedicated control path already exists. If you look at the gateway*, it inherits from control-template which sets the ControlPath and I've verified that the socket file is created in ~/.ssh/%h_control.sock upon connection to either of the bastion hosts.

Am I missing something?

@stk0vrfl0w
Copy link
Contributor Author

Maybe this would help explain my use case scenario. In order for me to get to the FrankNetwork, I need to first go through one of the gateway systems (requiring 2-factor auth). From there, I can go to Frankbastion and then finally into the Franknetwork. Similar rules apply for BeansNetwork, etc.

                  +------------+
 o                |            |  ->  Frankbastion  ->  FrankNetwork
/|\       ->      |  Gateways  |       
/ \               |            |  ->  Beansbastion  ->  BeansNetwork
     ControlPath  +------------+

To take advantage of only having to 2-factor authenticate once for the gateways, I setup a ControlPath only to them and then have DynamicForward for bastion hosts. I'd assumed that I've written the assh.yml correctly because it seems to do what I want -- except for the fact the a temporary directory is getting created even if ControlPath is defined and getting used.

Seems that because I don't have a ControlPath defined for Frankbastion or Beansbastion, assh is automatically creating a temp directory for their defined gateways -- even though the gateway has a ControlPath defined.

I've also noted that setting ControlMaster no / ControlPath none in the defaults won't prevent the creation of the temp directory. So... let's say I do ssh 172.31.29.255/172.16.254.0, a directory called 172.16.254.0 gets created in the current working directory.

All that said, I really appreciate you adding the ability to disable the auto-creation of directories.

@moul
Copy link
Owner

moul commented Mar 14, 2016

Hi @stk0vrfl0w, #128 should fix this problem by adding an option to disable the automatic creation of directories for gateways, I will give some tests and come back to you

@moul
Copy link
Owner

moul commented Mar 14, 2016

It seems good to me, you can upgrade assh and try again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants