+# remove all lines with specified string from specified file
+remove_line() {
+ local file
+ local string
+
+ file="$1"
+ string="$2"
+
+ # if the line is there are removed, return 0
+ if [ "$file" -a "$string" ] ; then
+ grep -v -F "$string" "$file" | sponge "$file"
+ return 0
+ # otherwise return 1
+ else
+ return 1
+ fi
+}
+
+# translate ssh-style path variables %h and %u
+translate_ssh_variables() {
+ local uname
+ local home
+
+ uname="$1"
+ path="$2"
+
+ # get the user's home directory
+ userHome=$(getent passwd "$uname" | cut -d: -f6)
+
+ # translate '%u' to user name
+ path=${path/\%u/"$uname"}
+ # translate '%h' to user home directory
+ path=${path/\%h/"$userHome"}
+
+ echo "$path"
+}
+
+### CONVERSION UTILITIES
+
+# output the ssh key for a given key ID
+gpg2ssh() {
+ local keyID
+
+ keyID="$1"
+
+ gpg --export "$keyID" | openpgp2ssh "$keyID" 2> /dev/null
+}
+
+# output known_hosts line from ssh key
+ssh2known_hosts() {
+ local host
+ local key
+
+ host="$1"
+ key="$2"
+
+ echo -n "$host "
+ echo -n "$key" | tr -d '\n'
+ echo " MonkeySphere${DATE}"
+}
+
+# output authorized_keys line from ssh key
+ssh2authorized_keys() {
+ local userID
+ local key
+
+ userID="$1"
+ key="$2"
+
+ echo -n "$key" | tr -d '\n'
+ echo " MonkeySphere${DATE} ${userID}"
+}
+