This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

Re: Ability to add toplevel commands to ~/.ssh/config

Tony O
Message ID
DKIM signature
Download raw message
ixmpp says: would be nice to be able to `Include <file>` in ssh/config... im not able to use that module right now cause i need that

abcdw: What prevents you from doing so?

ixmpp: abcdw: theres no option to? Its exclusively host and match blocks

abcdw: ixmpp: Ok, I see. Can we put Include in default-options, it will work for all hosts because of "Host *"? Or it must be top-level?

ixmpp: Top-level. Either that or a text trapdoor would be nice

abcdw: ixmpp: ok, can you create a topic for that in rde-devel please?

ixmpp: Sure. Just a sec

Ix @ libera

[PATCH] gnu: home-services: ssh: Support toplevel options.

Message ID
<XNh-7CLvmQPB70oQ7r5c1spO7t8NotWPYKyeKKBqnTF44zmB31BDYAUhUNrUNo9Miftg2MaQxOrMcY33ZuC4kg==@fron.io> (view parent)
DKIM signature
Download raw message
Patch: +26 -2
* gnu/home-services/ssh.scm (serialize-field): Add optional keyword
argument ’toplevel?’
(serialize-toplevel-alist): New procedure.
(home-ssh-configuration): Add ‘toplevel-option’ field.

Suggested-by: Tony O <me@fron.io>
Link: https://lists.sr.ht/~abcdw/rde-devel/%3CXNh-7CLvmQPB70oQ7r5c1spO7t8NotWPYKyeKKBqnTF44zmB31BDYAUhUNrUNo9Miftg2MaQxOrMcY33ZuC4kg%3D%3D%40fron.io%3E
Is this what you want?

This config

--8<---------------cut here---------------start------------->8---
(service home-ssh-service-type
                 (forward-agent #f)
                  '((include . "/path/to/file")))
                   '((compression . #f)
                     (server-alive-interval . 0)
                     (server-alive-count-max . 3)
                     (add-keys-to-agent . #t)))))
--8<---------------cut here---------------end--------------->8---

Yields the following in ~/.ssh/config

--8<---------------cut here---------------start------------->8---
Host *
  UserKnownHostsFile ~/.ssh/known_hosts
  ForwardAgent no
  Compression no
  ServerAliveInterval 0
  ServerAliveCountMax 3
  AddKeysToAgent yes
Include /path/to/file
--8<---------------cut here---------------end--------------->8---

 gnu/home-services/ssh.scm | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/gnu/home-services/ssh.scm b/gnu/home-services/ssh.scm
index 0ba945f..fba552b 100644
--- a/gnu/home-services/ssh.scm
+++ b/gnu/home-services/ssh.scm
@@ -34,13 +34,14 @@
  (let ((str (symbol->string field-name)))
    (apply string-append (map string-capitalize (string-split str #\-)))))

(define (serialize-field field-name val)
(define* (serialize-field field-name val #:key (toplevel? #f))
   ((boolean? val) (serialize-boolean field-name val))
   ((list? val) (serialize-list field-name val))
    (let ((field-name (uglify-field-name field-name)))
      (if (member field-name '("Host" "Match"))
      (if (or (member field-name '("Host" "Match"))
          (format #f "~a ~a\n" field-name val)
          (format #f "  ~a ~a\n" field-name val))))))

@@ -53,6 +54,13 @@
(define (serialize-alist field-name val)
  (generic-serialize-alist string-append serialize-field val))

(define (serialize-toplevel-alist field-name val)
   (lambda (field-name val)
     (serialize-field field-name val #:toplevel? #t))

(define (serialize-extra-config field-name val)
  (define serialize-extra-config-entry
@@ -159,6 +167,22 @@ Host *
  AddKeysToAgent yes
  AddressFamily inet
@end example")
   (alist '())
   "Association list of toplevel configuration options.  The configuration below:

    '((include . \"/some/path/to/file\"))))
@end lisp

would this:

Include /some/path/to/file
@end example"
   (ssh-host-or-ssh-match '())
   "List of configurations for other hosts.  Something like this:

base-commit: cd7a30e9f860899a11bfad0e42d283ed746b7250
Reply to thread Export thread (mbox)