Created
June 1, 2011 18:23
-
-
Save hugoduncan/1002932 to your computer and use it in GitHub Desktop.
record-public-key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn record-public-key | |
"Record a public key" | |
[session user & {:keys [filename type parameter-path] | |
:or {type "rsa"} :as options}] | |
(let [filename (or filename (ssh-default-filenames type)) | |
path (str (user-ssh-dir user) filename ".pub")] | |
(-> | |
session | |
(remote-file/with-remote-file | |
(action/as-clj-action | |
(fn [session local-path] | |
(let [pub-key (slurp local-path)] | |
(if-not (string/blank? pub-key) | |
(if parameter-path | |
(parameter/update-for-service | |
session parameter-path | |
(fn [keys] (conj (or keys #{}) pub-key))) | |
(parameter/assoc-for-target | |
session [:user (keyword user) (keyword filename)] pub-key)) | |
session))) | |
[session]) | |
path)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment