Jelajahi Sumber

add a convinience option to install the ssh-agent loaded public keys into a remote account's ~/.ssh/authorized_keys

Ralf S. Engelschall 22 tahun lalu
induk
melakukan
20f5d13e88
3 mengubah file dengan 25 tambahan dan 4 penghapusan
  1. 1 1
      openssh/openssh.spec
  2. 18 3
      openssh/ssh-keyman
  3. 6 0
      openssh/ssh-keyman.pod

+ 1 - 1
openssh/openssh.spec

@@ -41,7 +41,7 @@ Distribution: OpenPKG [CORE]
 Group:        Security
 License:      BSD
 Version:      %{V_base}%{V_portable}
-Release:      20031223
+Release:      20031231
 
 #   package options
 %option       with_fsl      yes

+ 18 - 3
openssh/ssh-keyman

@@ -32,6 +32,7 @@ prog_date="31-May-2002"
 #   OpenSSH programs
 ssh_agent="@l_prefix@/bin/ssh-agent"
 ssh_add="@l_prefix@/bin/ssh-add"
+ssh="@l_prefix@/bin/ssh"
 
 #   parse command line options
 opt_q=no; alias_quiet=q
@@ -42,6 +43,7 @@ opt_k=no; alias_kill=k
 opt_a=no; alias_add=a
 opt_d=no; alias_delete=d
 opt_l=no; alias_list=l
+opt_i=no; alias_install=i
 opt_h=no; alias_help=h
 opt_v=no; alias_version=v
 if [ $# -eq 0 ]; then
@@ -58,7 +60,7 @@ while [ $# -gt 0 ]; do
             eval "name=\$alias_${name}"
             eval "opt_${name}=yes"
             ;;
-        -[qceskadlhv] )
+        -[qceskadlihv] )
             name=`echo x$1 | sed -e 's;^x-;;'`
             eval "opt_${name}=yes"
             ;;
@@ -75,7 +77,7 @@ done
 
 #   stand-alone operation: display help information
 if [ ".$opt_h" = .yes ]; then
-    echo "Usage: $prog_name [-h] [-v] [-q] [-c] [-e] [-s] [-k] [-a] [-d] [-l] [keyfile ...]"
+    echo "Usage: $prog_name [-h] [-v] [-q] [-c] [-e] [-s] [-k] [-a] [-d] [-l] [-i] [keyfile ...]"
     exit 0
 fi
 
@@ -108,7 +110,7 @@ check_agent_info () {
         if [ ! -r $SSH_AUTH_SOCK ]; then
             invalid1="agent socket $SSH_AUTH_SOCK no longer exists"
         else
-            ssh-add -l >/dev/null 2>&1
+            $ssh_add -l >/dev/null 2>&1
             if [ $? -eq 2 ]; then
                 invalid1="agent socket $SSH_AUTH_SOCK no longer valid"
             fi
@@ -288,3 +290,16 @@ if [ ".$opt_l" = .yes ]; then
     fi
 fi
 
+#   install key(s) into remote account
+if [ ".$opt_i" = .yes ]; then
+    if [ ".$SSH_AUTH_SOCK" = . ]; then
+        echo "$prog_name:WARNING: agent not available" 1>&2
+    else
+        for remote in "$@"; do
+            echo "$prog_name: installing public keys into $remote"
+            $ssh_add -L |\
+            $ssh $remote "umask 077; test -d ~/.ssh || mkdir ~/.ssh; cat >>~/.ssh/authorized_keys"
+        done
+    fi
+fi
+

+ 6 - 0
openssh/ssh-keyman.pod

@@ -40,6 +40,7 @@ B<ssh-keyman>
 [B<-d>]
 [B<-a>]
 [B<-l>]
+[B<-i>]
 [I<keyfile> ...]
 
 B<ssh-keyman> 
@@ -106,6 +107,11 @@ minimum.
 List keys. This lists the currently available keys in the B<ssh-agent>
 process.
 
+=item B<-i>, B<--install>
+
+Install public keys into remote account. This extracts the currently available public keys in the B<ssh-agent>
+process and installs them into "C<~/.ssh/authorized_keys>" on a specified remote account.
+
 =item B<-h>, B<--help>
 
 Help information. Display a usage summary on F<stdout>.