summaryrefslogtreecommitdiff
path: root/gnu/services/ssh.scm
diff options
context:
space:
mode:
authorAndreas Enge <andreas@enge.fr>2025-11-18 17:23:45 +0100
committerAndreas Enge <andreas@enge.fr>2025-11-21 14:35:35 +0100
commite1a3b41a4ba0d438559af5a8bbecd6383b226396 (patch)
tree5159a53525aeb37ade3c73fe51e764715b05ca7f /gnu/services/ssh.scm
parentad30252858f066e0b2ec46650e9a8edbc5486699 (diff)
gnu: Remove lsh-service-type.
* gnu/services/ssh.scm (<lsh-configuration>, %yarrow-seed, lsh-initialization, lsh-activation, lsh-shepherd-service, lsh-pam-services, lsh-service-type): Delete variables. * doc/guix.texi: Remove lsh-service-type documentation. Change-Id: I18377a111c10ec6f6d362fadabc64cb66a2b122d
Diffstat (limited to 'gnu/services/ssh.scm')
-rw-r--r--gnu/services/ssh.scm173
1 files changed, 1 insertions, 172 deletions
diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm
index aac6c1e3539..77359501e4c 100644
--- a/gnu/services/ssh.scm
+++ b/gnu/services/ssh.scm
@@ -40,11 +40,7 @@
40 #:use-module (srfi srfi-26) 40 #:use-module (srfi srfi-26)
41 #:use-module (ice-9 match) 41 #:use-module (ice-9 match)
42 #:use-module (ice-9 vlist) 42 #:use-module (ice-9 vlist)
43 #:export (lsh-configuration 43 #:export (openssh-configuration
44 lsh-configuration?
45 lsh-service-type
46
47 openssh-configuration
48 openssh-configuration? 44 openssh-configuration?
49 openssh-configuration-openssh 45 openssh-configuration-openssh
50 openssh-configuration-pid-file 46 openssh-configuration-pid-file
@@ -87,173 +83,6 @@
87;;; 83;;;
88;;; This module implements secure shell (SSH) services. 84;;; This module implements secure shell (SSH) services.
89;;; 85;;;
90;;; Code:
91
92(define-record-type* <lsh-configuration>
93 lsh-configuration make-lsh-configuration
94 lsh-configuration?
95 (lsh lsh-configuration-lsh
96 (default lsh))
97 (daemonic? lsh-configuration-daemonic?
98 (default #t))
99 (host-key lsh-configuration-host-key
100 (default "/etc/lsh/host-key"))
101 (interfaces lsh-configuration-interfaces
102 (default '()))
103 (port-number lsh-configuration-port-number
104 (default 22))
105 (allow-empty-passwords? lsh-configuration-allow-empty-passwords?
106 (default #f))
107 (root-login? lsh-configuration-root-login?
108 (default #f))
109 (syslog-output? lsh-configuration-syslog-output?
110 (default #t))
111 (pid-file? lsh-configuration-pid-file?
112 (default #f))
113 (pid-file lsh-configuration-pid-file
114 (default "/var/run/lshd.pid"))
115 (x11-forwarding? lsh-configuration-x11-forwarding?
116 (default #t))
117 (tcp/ip-forwarding? lsh-configuration-tcp/ip-forwarding?
118 (default #t))
119 (password-authentication? lsh-configuration-password-authentication?
120 (default #t))
121 (public-key-authentication? lsh-configuration-public-key-authentication?
122 (default #t))
123 (initialize? lsh-configuration-initialize?
124 (default #t)))
125
126(define %yarrow-seed
127 "/var/spool/lsh/yarrow-seed-file")
128
129(define (lsh-initialization lsh host-key)
130 "Return the gexp to initialize the LSH service for HOST-KEY."
131 #~(begin
132 (unless (file-exists? #$%yarrow-seed)
133 (system* (string-append #$lsh "/bin/lsh-make-seed")
134 "--sloppy" "-o" #$%yarrow-seed))
135
136 (unless (file-exists? #$host-key)
137 (mkdir-p (dirname #$host-key))
138 (format #t "creating SSH host key '~a'...~%" #$host-key)
139
140 ;; FIXME: We're just doing a simple pipeline, but 'system' cannot be
141 ;; used yet because /bin/sh might be dangling; factorize this somehow.
142 (let* ((in+out (pipe))
143 (keygen (primitive-fork)))
144 (case keygen
145 ((0)
146 (close-port (car in+out))
147 (close-fdes 1)
148 (dup2 (fileno (cdr in+out)) 1)
149 (execl (string-append #$lsh "/bin/lsh-keygen")
150 "lsh-keygen" "--server"))
151 (else
152 (let ((write-key (primitive-fork)))
153 (case write-key
154 ((0)
155 (close-port (cdr in+out))
156 (close-fdes 0)
157 (dup2 (fileno (car in+out)) 0)
158 (execl (string-append #$lsh "/bin/lsh-writekey")
159 "lsh-writekey" "--server" "-o" #$host-key))
160 (else
161 (close-port (car in+out))
162 (close-port (cdr in+out))
163 (waitpid keygen)
164 (waitpid write-key))))))))))
165
166(define (lsh-activation config)
167 "Return the activation gexp for CONFIG."
168 #~(begin
169 (use-modules (guix build utils))
170 (mkdir-p "/var/spool/lsh")
171 #$(if (lsh-configuration-initialize? config)
172 (lsh-initialization (lsh-configuration-lsh config)
173 (lsh-configuration-host-key config))
174 #t)))
175
176(define (lsh-shepherd-service config)
177 "Return a <shepherd-service> for lsh with CONFIG."
178 (define lsh (lsh-configuration-lsh config))
179 (define pid-file (lsh-configuration-pid-file config))
180 (define pid-file? (lsh-configuration-pid-file? config))
181 (define daemonic? (lsh-configuration-daemonic? config))
182 (define interfaces (lsh-configuration-interfaces config))
183
184 (define lsh-command
185 (append
186 (cons (file-append lsh "/sbin/lshd")
187 (if daemonic?
188 (let ((syslog (if (lsh-configuration-syslog-output? config)
189 '()
190 (list "--no-syslog"))))
191 (cons "--daemonic"
192 (if pid-file?
193 (cons #~(string-append "--pid-file=" #$pid-file)
194 syslog)
195 (cons "--no-pid-file" syslog))))
196 (if pid-file?
197 (list #~(string-append "--pid-file=" #$pid-file))
198 '())))
199 (cons* #~(string-append "--host-key="
200 #$(lsh-configuration-host-key config))
201 #~(string-append "--password-helper=" #$lsh "/sbin/lsh-pam-checkpw")
202 #~(string-append "--subsystems=sftp=" #$lsh "/sbin/sftp-server")
203 "-p" (number->string (lsh-configuration-port-number config))
204 (if (lsh-configuration-password-authentication? config)
205 "--password" "--no-password")
206 (if (lsh-configuration-public-key-authentication? config)
207 "--publickey" "--no-publickey")
208 (if (lsh-configuration-root-login? config)
209 "--root-login" "--no-root-login")
210 (if (lsh-configuration-x11-forwarding? config)
211 "--x11-forward" "--no-x11-forward")
212 (if (lsh-configuration-tcp/ip-forwarding? config)
213 "--tcpip-forward" "--no-tcpip-forward")
214 (if (null? interfaces)
215 '()
216 (map (cut string-append "--interface=" <>)
217 interfaces)))))
218
219 (define requires
220 `(user-processes
221 networking
222 pam
223 ,@(if (and daemonic? (lsh-configuration-syslog-output? config))
224 '(syslogd)
225 '())))
226
227 (list (shepherd-service
228 (documentation "GNU lsh SSH server")
229 (provision '(ssh-daemon ssh sshd))
230 (requirement requires)
231 (start #~(make-forkexec-constructor (list #$@lsh-command)))
232 (stop #~(make-kill-destructor)))))
233
234(define (lsh-pam-services config)
235 "Return a list of <pam-services> for lshd with CONFIG."
236 (list (unix-pam-service
237 "lshd"
238 #:login-uid? #t
239 #:allow-empty-passwords?
240 (lsh-configuration-allow-empty-passwords? config))))
241
242(define lsh-service-type
243 (service-type
244 (name 'lsh)
245 (extensions
246 (list (service-extension shepherd-root-service-type
247 lsh-shepherd-service)
248 (service-extension pam-root-service-type
249 lsh-pam-services)
250 (service-extension activation-service-type
251 lsh-activation)))
252 (description "Run the GNU@tie{}lsh secure shell (SSH) daemon,
253@command{lshd}.")
254 (default-value (lsh-configuration))))
255
256;;;
257;;; OpenSSH. 86;;; OpenSSH.
258;;; 87;;;
259 88