diff options
author | joe <joe@jerkface.net> | 2014-08-01 00:04:33 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-08-01 00:04:33 -0400 |
commit | f5b586b541d6b8703a6fef3e09aabf563683c4e8 (patch) | |
tree | 69452f9c8bdd0ccdc9d80ef6686baffdaf73c252 /kiki.hs | |
parent | 9fa0ed75d7607bf534d25f2deea8c78835fabe02 (diff) |
export public ssh keys
Diffstat (limited to 'kiki.hs')
-rw-r--r-- | kiki.hs | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -299,15 +299,17 @@ show_pem keyspec wkgrip db = do | |||
299 | putStrLn $ | 299 | putStrLn $ |
300 | writePEM "PUBLIC KEY" qq -- ("TODO "++show keyspec) | 300 | writePEM "PUBLIC KEY" qq -- ("TODO "++show keyspec) |
301 | 301 | ||
302 | show_ssh keyspec wkgrip db = do | 302 | show_ssh keyspec wkgrip db = either warn putStrLn $ show_ssh' keyspec wkgrip db |
303 | |||
304 | show_ssh' keyspec wkgrip db = do | ||
303 | let s = parseSpec wkgrip keyspec | 305 | let s = parseSpec wkgrip keyspec |
304 | flip (maybe . void $ warn (keyspec ++ ": not found")) | 306 | flip (maybe . Left $ keyspec ++ ": not found") |
305 | (selectPublicKey s db) | 307 | (selectPublicKey s db) |
306 | $ \k -> do | 308 | $ \k -> do |
307 | let Just (RSAKey (MPI n) (MPI e)) = rsaKeyFromPacket k | 309 | let Just (RSAKey (MPI n) (MPI e)) = rsaKeyFromPacket k |
308 | bs = sshrsa e n | 310 | bs = sshrsa e n |
309 | blob = Base64.encode (L.unpack bs) | 311 | blob = Base64.encode (L.unpack bs) |
310 | putStrLn $ "ssh-rsa " ++ blob | 312 | return $ "ssh-rsa " ++ blob |
311 | 313 | ||
312 | show_id keyspec wkgrip db = do | 314 | show_id keyspec wkgrip db = do |
313 | let s = parseSpec "" keyspec | 315 | let s = parseSpec "" keyspec |
@@ -1222,9 +1224,15 @@ kiki "init-key" args = do | |||
1222 | rt <- unconditionally $ return rt | 1224 | rt <- unconditionally $ return rt |
1223 | 1225 | ||
1224 | -- Finally, export public keys if they do not exist. | 1226 | -- Finally, export public keys if they do not exist. |
1225 | -- TODO | 1227 | flip (maybe $ warn "missing working key?") (rtGrip rt) $ \grip -> do |
1226 | -- makepub ssh-client "$ROOT/root/.ssh/id_rsa.pub" | 1228 | gotc <- doesFileExist (sshcpath++".pub") |
1227 | -- makepub ssh-host "$ROOT/etc/ssh/ssh_host_rsa_key.pub" | 1229 | when (not gotc) $ do |
1230 | either warn (writeFile $ sshcpath++".pub") | ||
1231 | $ show_ssh' "ssh-client" grip (rtKeyDB rt) | ||
1232 | goth <- doesFileExist (sshspath++".pub") | ||
1233 | when (not goth) $ do | ||
1234 | either warn (writeFile $ sshspath++".pub") | ||
1235 | $ show_ssh' "ssh-host" grip (rtKeyDB rt) | ||
1228 | 1236 | ||
1229 | return () | 1237 | return () |
1230 | 1238 | ||