sshPubKey is renamed to Ssh.pubKey, and has an added SshKeyType parameter.
This commit is contained in:
parent
52664e6220
commit
f1a1d0001a
|
@ -278,7 +278,7 @@ elephant = standardSystem "elephant.kitenet.net" Unstable "amd64"
|
|||
& Systemd.installed
|
||||
& Systemd.persistentJournal
|
||||
& Ssh.hostKeys hostContext
|
||||
& Ssh.pubKey "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBAJkoPRhUGT8EId6m37uBdYEtq42VNwslKnc9mmO+89ody066q6seHKeFY6ImfwjcyIjM30RTzEwftuVNQnbEB0="
|
||||
& Ssh.pubKey SshEcdsa "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBAJkoPRhUGT8EId6m37uBdYEtq42VNwslKnc9mmO+89ody066q6seHKeFY6ImfwjcyIjM30RTzEwftuVNQnbEB0="
|
||||
& Ssh.keyImported SshRsa "joey" hostContext
|
||||
& Apt.serviceInstalledRunning "swapspace"
|
||||
|
||||
|
@ -459,9 +459,9 @@ myDnsPrimary dnssec domain extras = (if dnssec then Dns.signedPrimary (Weekly No
|
|||
monsters :: [Host] -- Systems I don't manage with propellor,
|
||||
monsters = -- but do want to track their public keys etc.
|
||||
[ host "usw-s002.rsync.net"
|
||||
& Ssh.pubKey "ssh-dss AAAAB3NzaC1kc3MAAAEBAI6ZsoW8a+Zl6NqUf9a4xXSMcV1akJHDEKKBzlI2YZo9gb9YoCf5p9oby8THUSgfh4kse7LJeY7Nb64NR6Y/X7I2/QzbE1HGGl5mMwB6LeUcJ74T3TQAlNEZkGt/MOIVLolJHk049hC09zLpkUDtX8K0t1yaCirC9SxDGLTCLEhvU9+vVdVrdQlKZ9wpLUNbdAzvbra+O/IVvExxDZ9WCHrnfNA8ddVZIGEWMqsoNgiuCxiXpi8qL+noghsSQNFTXwo7W2Vp9zj1JkCt3GtSz5IzEpARQaXEAWNEM0n1nJ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IFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="
|
||||
& Ssh.pubKey SshRsa "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="
|
||||
, host "ns6.gandi.net"
|
||||
& ipv4 "217.70.177.40"
|
||||
, host "turtle.kitenet.net"
|
||||
|
@ -469,7 +469,7 @@ monsters = -- but do want to track their public keys etc.
|
|||
& ipv6 "2001:4978:f:2d9::2"
|
||||
& alias "backup.kitenet.net"
|
||||
& alias "usbackup.kitenet.net"
|
||||
& Ssh.pubKey "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAokMXQiX/NZjA1UbhMdgAscnS5dsmy+Q7bWrQ6tsTZ/o+6N/T5cbjoBHOdpypXJI3y/PiJTDJaQtXIhLa8gFg/EvxMnMz/KG9skADW1361JmfCc4BxicQIO2IOOe6eilPr+YsnOwiHwL0vpUnuty39cppuMWVD25GzxXlS6KQsLCvXLzxLLuNnGC43UAM0q4UwQxDtAZEK1dH2o3HMWhgMP2qEQupc24dbhpO3ecxh2C9678a3oGDuDuNf7mLp3s7ptj5qF3onitpJ82U5o7VajaHoygMaSRFeWxP2c13eM57j3bLdLwxVXFhePcKXARu1iuFTLS5uUf3hN6MkQcOGw=="
|
||||
& Ssh.pubKey SshRsa "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAokMXQiX/NZjA1UbhMdgAscnS5dsmy+Q7bWrQ6tsTZ/o+6N/T5cbjoBHOdpypXJI3y/PiJTDJaQtXIhLa8gFg/EvxMnMz/KG9skADW1361JmfCc4BxicQIO2IOOe6eilPr+YsnOwiHwL0vpUnuty39cppuMWVD25GzxXlS6KQsLCvXLzxLLuNnGC43UAM0q4UwQxDtAZEK1dH2o3HMWhgMP2qEQupc24dbhpO3ecxh2C9678a3oGDuDuNf7mLp3s7ptj5qF3onitpJ82U5o7VajaHoygMaSRFeWxP2c13eM57j3bLdLwxVXFhePcKXARu1iuFTLS5uUf3hN6MkQcOGw=="
|
||||
, host "old.kitenet.net"
|
||||
& ipv4 "80.68.85.49"
|
||||
, host "mouse.kitenet.net"
|
||||
|
|
|
@ -6,7 +6,8 @@ propellor (1.3.0) UNRELEASED; urgency=medium
|
|||
that docker exec doesn't enter a chroot.
|
||||
* Update intermediary propellor in --spin --via
|
||||
* Added support for DNSSEC.
|
||||
* sshPubKey is renamed to Ssh.pubKey
|
||||
* sshPubKey is renamed to Ssh.pubKey, and has an added SshKeyType
|
||||
parameter.
|
||||
* Fix build with process 1.2.1.0.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Thu, 01 Jan 2015 13:27:23 -0400
|
||||
|
|
|
@ -55,7 +55,7 @@ withPrivData
|
|||
-> Property
|
||||
withPrivData s = withPrivData' snd [s]
|
||||
|
||||
-- Like withPrivData, but here any of a list of PrivDataFields can be used.
|
||||
-- Like withPrivData, but here any one of a list of PrivDataFields can be used.
|
||||
withSomePrivData
|
||||
:: (IsContext c, IsPrivDataSource s)
|
||||
=> [s]
|
||||
|
|
|
@ -23,6 +23,7 @@ import Utility.SafeCommand
|
|||
import Utility.FileMode
|
||||
|
||||
import System.PosixCompat
|
||||
import qualified Data.Map as M
|
||||
|
||||
sshBool :: Bool -> String
|
||||
sshBool True = "yes"
|
||||
|
@ -80,16 +81,16 @@ randomHostKeys = flagFile prop "/etc/ssh/.unique_host_keys"
|
|||
ensureProperty $ scriptProperty
|
||||
[ "DPKG_MAINTSCRIPT_NAME=postinst DPKG_MAINTSCRIPT_PACKAGE=openssh-server /var/lib/dpkg/info/openssh-server.postinst configure" ]
|
||||
|
||||
-- | When a host has a well-known public key, this can be used to indicate
|
||||
-- what the key is. It does not cause the key to be installed.
|
||||
pubKey :: String -> Property
|
||||
pubKey k = pureInfoProperty ("ssh pubkey known") $
|
||||
mempty { _sshPubKey = Val k }
|
||||
-- | When a host has a well-known public host key, this can be used
|
||||
-- to indicate what the key is. It does not cause the key to be installed.
|
||||
pubKey :: SshKeyType -> String -> Property
|
||||
pubKey t k = pureInfoProperty ("ssh pubkey known") $
|
||||
mempty { _sshPubKey = M.singleton t k }
|
||||
|
||||
getPubKey :: Propellor (Maybe String)
|
||||
getPubKey = askInfo _sshPubKey
|
||||
getPubKey :: Propellor (M.Map SshKeyType String)
|
||||
getPubKey = asks (_sshPubKey . hostInfo)
|
||||
|
||||
-- | Installs all commonly used types of ssh host keys from the privdata.
|
||||
-- | Installs all commonly used types of ssh host keys.
|
||||
hostKeys :: IsContext c => c -> Property
|
||||
hostKeys ctx = propertyList "known ssh host keys"
|
||||
[ hostKey SshDsa ctx
|
||||
|
@ -97,7 +98,11 @@ hostKeys ctx = propertyList "known ssh host keys"
|
|||
, hostKey SshEcdsa ctx
|
||||
]
|
||||
|
||||
-- | Installs a single ssh host key from the privdata.
|
||||
-- | Installs a single ssh host key.
|
||||
--
|
||||
-- The private key comes from the privdata.
|
||||
--
|
||||
-- The public key is set using 'pubKey'.
|
||||
hostKey :: IsContext c => SshKeyType -> c -> Property
|
||||
hostKey keytype context = combineProperties desc
|
||||
[ installkey (keysrc ".pub" (SshPubKey keytype "")) (install writeFile ".pub")
|
||||
|
@ -150,22 +155,23 @@ fromKeyType SshDsa = "dsa"
|
|||
fromKeyType SshEcdsa = "ecdsa"
|
||||
fromKeyType SshEd25519 = "ed25519"
|
||||
|
||||
-- | Puts some host's ssh public key, as set using 'pubKey',
|
||||
-- | Puts some host's ssh public key(s), as set using 'pubKey',
|
||||
-- into the known_hosts file for a user.
|
||||
knownHost :: [Host] -> HostName -> UserName -> Property
|
||||
knownHost hosts hn user = property desc $
|
||||
go =<< fromHost hosts hn getPubKey
|
||||
where
|
||||
desc = user ++ " knows ssh key for " ++ hn
|
||||
go (Just (Just k)) = do
|
||||
go (Just m) | not (M.null m) = do
|
||||
f <- liftIO $ dotFile "known_hosts" user
|
||||
ensureProperty $ combineProperties desc
|
||||
[ File.dirExists (takeDirectory f)
|
||||
, f `File.containsLine` (hn ++ " " ++ k)
|
||||
, f `File.containsLines`
|
||||
(map (\k -> hn ++ " " ++ k) (M.elems m))
|
||||
, File.ownerGroup f user user
|
||||
]
|
||||
go _ = do
|
||||
warningMessage $ "no configred sshPubKey for " ++ hn
|
||||
warningMessage $ "no configred pubKey for " ++ hn
|
||||
return FailedChange
|
||||
|
||||
-- | Makes a user have authorized_keys from the PrivData
|
||||
|
|
|
@ -37,6 +37,7 @@ import System.Posix.Types
|
|||
import "mtl" Control.Monad.RWS.Strict
|
||||
import "MonadCatchIO-transformers" Control.Monad.CatchIO
|
||||
import qualified Data.Set as S
|
||||
import qualified Data.Map as M
|
||||
import qualified Propellor.Types.Dns as Dns
|
||||
|
||||
import Propellor.Types.OS
|
||||
|
@ -176,7 +177,7 @@ data CmdLine
|
|||
data Info = Info
|
||||
{ _os :: Val System
|
||||
, _privDataFields :: S.Set (PrivDataField, HostContext)
|
||||
, _sshPubKey :: Val String
|
||||
, _sshPubKey :: M.Map SshKeyType String
|
||||
, _aliases :: S.Set HostName
|
||||
, _dns :: S.Set Dns.Record
|
||||
, _namedconf :: Dns.NamedConfMap
|
||||
|
@ -190,7 +191,7 @@ instance Monoid Info where
|
|||
mappend old new = Info
|
||||
{ _os = _os old <> _os new
|
||||
, _privDataFields = _privDataFields old <> _privDataFields new
|
||||
, _sshPubKey = _sshPubKey old <> _sshPubKey new
|
||||
, _sshPubKey = _sshPubKey new `M.union` _sshPubKey old
|
||||
, _aliases = _aliases old <> _aliases new
|
||||
, _dns = _dns old <> _dns new
|
||||
, _namedconf = _namedconf old <> _namedconf new
|
||||
|
|
Loading…
Reference in New Issue