summaryrefslogtreecommitdiff
path: root/gnu/services/ssh.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/services/ssh.scm')
-rw-r--r--gnu/services/ssh.scm97
1 files changed, 92 insertions, 5 deletions
diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm
index 33e1951a6e7..743b5e3805a 100644
--- a/gnu/services/ssh.scm
+++ b/gnu/services/ssh.scm
@@ -1,5 +1,6 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2016 David Craven <david@craven.ch>
3;;; 4;;;
4;;; This file is part of GNU Guix. 5;;; This file is part of GNU Guix.
5;;; 6;;;
@@ -17,14 +18,19 @@
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. 18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18 19
19(define-module (gnu services ssh) 20(define-module (gnu services ssh)
20 #:use-module (guix gexp) 21 #:use-module (gnu packages ssh)
21 #:use-module (guix records)
22 #:use-module (gnu services) 22 #:use-module (gnu services)
23 #:use-module (gnu services shepherd) 23 #:use-module (gnu services shepherd)
24 #:use-module (gnu system pam) 24 #:use-module (gnu system pam)
25 #:use-module (gnu packages lsh) 25 #:use-module (guix gexp)
26 #:use-module (guix records)
26 #:use-module (srfi srfi-26) 27 #:use-module (srfi srfi-26)
27 #:export (lsh-service)) 28 #:export (lsh-service
29
30 dropbear-configuration
31 dropbear-configuration?
32 dropbear-service-type
33 dropbear-service))
28 34
29;;; Commentary: 35;;; Commentary:
30;;; 36;;;
@@ -235,4 +241,85 @@ The other options should be self-descriptive."
235 public-key-authentication?) 241 public-key-authentication?)
236 (initialize? initialize?)))) 242 (initialize? initialize?))))
237 243
244
245;;;
246;;; Dropbear.
247;;;
248
249(define-record-type* <dropbear-configuration>
250 dropbear-configuration make-dropbear-configuration
251 dropbear-configuration?
252 (dropbear dropbear-configuration-dropbear
253 (default dropbear))
254 (port-number dropbear-configuration-port-number
255 (default 22))
256 (syslog-output? dropbear-configuration-syslog-output?
257 (default #t))
258 (pid-file dropbear-configuration-pid-file
259 (default "/var/run/dropbear.pid"))
260 (root-login? dropbear-configuration-root-login?
261 (default #f))
262 (allow-empty-passwords? dropbear-configuration-allow-empty-passwords?
263 (default #f))
264 (password-authentication? dropbear-configuration-password-authentication?
265 (default #t)))
266
267(define (dropbear-activation config)
268 "Return the activation gexp for CONFIG."
269 #~(begin
270 (mkdir-p "/etc/dropbear")))
271
272(define (dropbear-shepherd-service config)
273 "Return a <shepherd-service> for dropbear with CONFIG."
274 (define dropbear
275 (dropbear-configuration-dropbear config))
276
277 (define pid-file
278 (dropbear-configuration-pid-file config))
279
280 (define dropbear-command
281 #~(list (string-append #$dropbear "/sbin/dropbear")
282
283 ;; '-R' allows host keys to be automatically generated upon first
284 ;; connection, at a time when /dev/urandom is more likely securely
285 ;; seeded.
286 "-F" "-R"
287
288 "-p" #$(number->string (dropbear-configuration-port-number config))
289 "-P" #$pid-file
290 #$@(if (dropbear-configuration-syslog-output? config) '() '("-E"))
291 #$@(if (dropbear-configuration-root-login? config) '() '("-w"))
292 #$@(if (dropbear-configuration-password-authentication? config)
293 '()
294 '("-s" "-g"))
295 #$@(if (dropbear-configuration-allow-empty-passwords? config)
296 '("-B")
297 '())))
298
299 (define requires
300 (if (dropbear-configuration-syslog-output? config)
301 '(networking syslogd) '(networking)))
302
303 (list (shepherd-service
304 (documentation "Dropbear SSH server.")
305 (requirement requires)
306 (provision '(ssh-daemon))
307 (start #~(make-forkexec-constructor #$dropbear-command
308 #:pid-file #$pid-file))
309 (stop #~(make-kill-destructor)))))
310
311(define dropbear-service-type
312 (service-type (name 'dropbear)
313 (extensions
314 (list (service-extension shepherd-root-service-type
315 dropbear-shepherd-service)
316 (service-extension activation-service-type
317 dropbear-activation)))))
318
319(define* (dropbear-service #:optional (config (dropbear-configuration)))
320 "Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
321daemon} with the given @var{config}, a @code{<dropbear-configuration>}
322object."
323 (service dropbear-service-type config))
324
238;;; ssh.scm ends here 325;;; ssh.scm ends here