From 3822c9a2d764a2ea451d4dce8862eef7dc697c12 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 Aug 2014 14:04:26 -0400 Subject: propellor spin --- src/Propellor/Property/Ssh.hs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/Propellor/Property/Ssh.hs') diff --git a/src/Propellor/Property/Ssh.hs b/src/Propellor/Property/Ssh.hs index 5a260476..41b93089 100644 --- a/src/Propellor/Property/Ssh.hs +++ b/src/Propellor/Property/Ssh.hs @@ -9,7 +9,8 @@ module Propellor.Property.Ssh ( hostKey, keyImported, knownHost, - authorizedKeys + authorizedKeys, + listenPort ) where import Propellor @@ -164,3 +165,18 @@ authorizedKeys user context = withPrivData (SshAuthorizedKeys user) context $ \g [ File.ownerGroup f user user , File.ownerGroup (takeDirectory f) user user ] + +-- | Makes the ssh server listen on a given port, in addition to any other +-- ports it is configured to listen on. +-- +-- Revert to prevent it listening on a particular port. +listenPort :: Int -> RevertableProperty +listenPort port = RevertableProperty enable disable + where + portline = "Port " ++ show port + enable = sshdConfig `File.containsLine` portline + `describe` ("ssh listening on " ++ portline) + `onChange` restartSshd + disable = sshdConfig `File.lacksLine` portline + `describe` ("ssh not listening on " ++ portline) + `onChange` restartSshd -- cgit v1.2.3