sshconf icon indicating copy to clipboard operation
sshconf copied to clipboard

parse included files

Open ezzra opened this issue 4 years ago • 8 comments

with Include filename you can separate your ssh configuration over several files, but sshconf is unfortunately not able to parse them

ezzra avatar Jul 05 '20 22:07 ezzra

@ezzra do you have need for both reading and writing such a configuration, or only parsing? Currently the library deals with only one file at a time, and include is just a setting in the file.

I will think about a wrapper to deal with includes if you have the need.

BR, Soren

sorend avatar Jul 17 '20 20:07 sorend

I would like to be able to add an Include to the main config file, and then do the rest of the work on the file I included. Thank you for all the work you've put into this lib so far :)

aviadra avatar Jul 18 '20 08:07 aviadra

@ezzra @aviadra : Can you try out 0.2.1 release of the library? Instead of invoking "write(filename)" you need to use the new "save()" method, which overwrites the existing files.

Let me know what you think -- feedback welcome :-)

Best regards, Soren

sorend avatar Jul 19 '20 22:07 sorend

So usage would be c.save() ? And how do I tell that I want to add an Include? I'm sorry I didn't follow

On Mon, Jul 20, 2020, 01:17 Søren A D [email protected] wrote:

@ezzra https://github.com/ezzra @aviadra https://github.com/aviadra : Can you try out 0.2.1 release of the library? Instead of invoking "write(filename)" you need to use the new "save()" method, which overwrites the existing files.

Let me know what you think -- feedback welcome :-)

Best regards, Soren

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sorend/sshconf/issues/5#issuecomment-660717936, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAP4WRPS2JCYXJVB3ERGENLR4NWI7ANCNFSM4ORCBC6Q .

aviadra avatar Jul 20 '20 05:07 aviadra

first reaction: update the readme to note that "empty_ssh_config" is now "empty_ssh_config_file"

On Mon, Jul 20, 2020 at 8:01 AM Aviad Raviv [email protected] wrote:

So usage would be c.save() ? And how do I tell that I want to add an Include? I'm sorry I didn't follow

On Mon, Jul 20, 2020, 01:17 Søren A D [email protected] wrote:

@ezzra https://github.com/ezzra @aviadra https://github.com/aviadra : Can you try out 0.2.1 release of the library? Instead of invoking "write(filename)" you need to use the new "save()" method, which overwrites the existing files.

Let me know what you think -- feedback welcome :-)

Best regards, Soren

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sorend/sshconf/issues/5#issuecomment-660717936, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAP4WRPS2JCYXJVB3ERGENLR4NWI7ANCNFSM4ORCBC6Q .

aviadra avatar Jul 20 '20 11:07 aviadra

Also image

aviadra avatar Jul 20 '20 14:07 aviadra

@aviadra -- thanks, I'll update it with some more examples (and fix the one I forgot :) ).

Some time since I've touched this project, but hope I can get it done today.

BR, Soren

sorend avatar Jul 20 '20 15:07 sorend

Thank you. And what about my include question?

On Mon, Jul 20, 2020, 18:15 Søren A D [email protected] wrote:

@aviadra https://github.com/aviadra -- thanks, I'll update it with some more examples (and fix the one I forgot :) ).

Some time since I've touched this project, but hope I can get it done today.

BR, Soren

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sorend/sshconf/issues/5#issuecomment-661102436, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAP4WRKUE33ESFYSZI5WEH3R4RNP3ANCNFSM4ORCBC6Q .

aviadra avatar Jul 20 '20 17:07 aviadra

Hi! I also have the same use case for reading the file, recently we split configs over multiple files which are included from ~/.ssh/config. The below code fails:

  BASTION_SSH_CONFIG=~/.ssh/config
  ssh_config = sshconf.read_ssh_config(BASTION_SSH_CONFIG)
  ssh_bastion = ssh_config.host(ssh_config_host)

  return SSHTunnelForwarder(
        ssh_bastion['hostname'],
        ssh_username=ssh_bastion['user'],
        ssh_pkey=ssh_bastion['identityfile'],
        remote_bind_address=(remote_host, remote_port)
    )

with

   ...
    ssh_bastion['hostname'],
KeyError: 'hostname'

I have to to set BASTION_SSH_CONFIG=~/.ssh/included_file.config for it to work.

dmarcelino avatar Oct 14 '24 12:10 dmarcelino