mgahagan / rpms / openssh

Forked from rpms/openssh 6 years ago
Clone
c3c35d5
diff -up openssh-6.4p1/contrib/ssh-copy-id.1.legacy-ssh-copy-id openssh-6.4p1/contrib/ssh-copy-id.1
c3c35d5
--- openssh-6.4p1/contrib/ssh-copy-id.1.legacy-ssh-copy-id	2013-03-22 00:17:37.000000000 +0100
c3c35d5
+++ openssh-6.4p1/contrib/ssh-copy-id.1	2014-01-28 17:12:49.197542425 +0100
c3c35d5
@@ -180,6 +180,19 @@ should prove enlightening (N.B. the mode
c3c35d5
 .Fl W
c3c35d5
 option, rather than
c3c35d5
 .Xr nc 1 ) .
c3c35d5
+.Sh ENVIRONMENT
c3c35d5
+.Bl -tag -width Ds
c3c35d5
+.Pp
c3c35d5
+.It Pa SSH_COPY_ID_LEGACY
c3c35d5
+If the 
c3c35d5
+.Cm SSH_COPY_ID_LEGACY
c3c35d5
+environment variable is set, the
c3c35d5
+.Nm
c3c35d5
+is run in a legacy mode. In this mode, the 
c3c35d5
+.Nm
c3c35d5
+doesn't check an existence of a private key and doesn't do remote checks
c3c35d5
+of the remote server versions or if public keys are already installed.
c3c35d5
+.El
c3c35d5
 .Sh "SEE ALSO"
c3c35d5
 .Xr ssh 1 ,
c3c35d5
 .Xr ssh-agent 1 ,
c3c35d5
diff -up openssh-6.4p1/contrib/ssh-copy-id.legacy-ssh-copy-id openssh-6.4p1/contrib/ssh-copy-id
c3c35d5
--- openssh-6.4p1/contrib/ssh-copy-id.legacy-ssh-copy-id	2013-06-05 14:48:45.000000000 +0200
c3c35d5
+++ openssh-6.4p1/contrib/ssh-copy-id	2014-01-28 17:11:51.538833032 +0100
b898cbf
@@ -77,7 +77,7 @@ use_id_file() {
b898cbf
     PUB_ID_FILE="$L_ID_FILE.pub"
b898cbf
   fi
b898cbf
 
b898cbf
-  PRIV_ID_FILE=$(dirname "$PUB_ID_FILE")/$(basename "$PUB_ID_FILE" .pub)
b898cbf
+  [ "x$SSH_COPY_ID_LEGACY" != "x" ] || PRIV_ID_FILE=$(dirname "$PUB_ID_FILE")/$(basename "$PUB_ID_FILE" .pub)
b898cbf
 
b898cbf
   # check that the files are readable
b898cbf
   for f in $PUB_ID_FILE $PRIV_ID_FILE ; do
b898cbf
@@ -243,7 +243,7 @@ populate_new_ids() {
b898cbf
   printf '%s: INFO: %d key(s) remain to be installed -- if you are prompted now it is to install the new keys\n' "$0" "$(printf '%s\n' "$NEW_IDS" | wc -l)" >&2
b898cbf
 }
b898cbf
 
b898cbf
-REMOTE_VERSION=$(ssh -v -o PreferredAuthentications=',' "$@" 2>&1 |
b898cbf
+[ "x$SSH_COPY_ID_LEGACY" != "x" ] || REMOTE_VERSION=$(ssh -v -o PreferredAuthentications=',' "$@" 2>&1 |
b898cbf
                  sed -ne 's/.*remote software version //p')
b898cbf
 
b898cbf
 case "$REMOTE_VERSION" in
b898cbf
@@ -268,7 +268,11 @@ case "$REMOTE_VERSION" in
b898cbf
     ;;
b898cbf
   *)
b898cbf
     # Assuming that the remote host treats ~/.ssh/authorized_keys as one might expect
b898cbf
-    populate_new_ids 0
b898cbf
+    if [ "x$SSH_COPY_ID_LEGACY" != "x" ]; then
b898cbf
+      NEW_IDS=`eval "$GET_ID"`
b898cbf
+    else
b898cbf
+      populate_new_ids 0
b898cbf
+    fi
b898cbf
     [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | ssh "$@" "
b898cbf
 		umask 077 ;
b898cbf
 		mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ;