rcolebaugh / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
Petr Lautrbach b898cb
diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id
Petr Lautrbach b898cb
index ae88e99..8e1091c 100644
Petr Lautrbach b898cb
--- a/contrib/ssh-copy-id
Petr Lautrbach b898cb
+++ b/contrib/ssh-copy-id
Petr Lautrbach b898cb
@@ -77,7 +77,7 @@ use_id_file() {
Petr Lautrbach b898cb
     PUB_ID_FILE="$L_ID_FILE.pub"
Petr Lautrbach b898cb
   fi
Petr Lautrbach b898cb
 
Petr Lautrbach b898cb
-  PRIV_ID_FILE=$(dirname "$PUB_ID_FILE")/$(basename "$PUB_ID_FILE" .pub)
Petr Lautrbach b898cb
+  [ "x$SSH_COPY_ID_LEGACY" != "x" ] || PRIV_ID_FILE=$(dirname "$PUB_ID_FILE")/$(basename "$PUB_ID_FILE" .pub)
Petr Lautrbach b898cb
 
Petr Lautrbach b898cb
   # check that the files are readable
Petr Lautrbach b898cb
   for f in $PUB_ID_FILE $PRIV_ID_FILE ; do
Petr Lautrbach b898cb
@@ -243,7 +243,7 @@ populate_new_ids() {
Petr Lautrbach b898cb
   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
Petr Lautrbach b898cb
 }
Petr Lautrbach b898cb
 
Petr Lautrbach b898cb
-REMOTE_VERSION=$(ssh -v -o PreferredAuthentications=',' "$@" 2>&1 |
Petr Lautrbach b898cb
+[ "x$SSH_COPY_ID_LEGACY" != "x" ] || REMOTE_VERSION=$(ssh -v -o PreferredAuthentications=',' "$@" 2>&1 |
Petr Lautrbach b898cb
                  sed -ne 's/.*remote software version //p')
Petr Lautrbach b898cb
 
Petr Lautrbach b898cb
 case "$REMOTE_VERSION" in
Petr Lautrbach b898cb
@@ -268,7 +268,11 @@ case "$REMOTE_VERSION" in
Petr Lautrbach b898cb
     ;;
Petr Lautrbach b898cb
   *)
Petr Lautrbach b898cb
     # Assuming that the remote host treats ~/.ssh/authorized_keys as one might expect
Petr Lautrbach b898cb
-    populate_new_ids 0
Petr Lautrbach b898cb
+    if [ "x$SSH_COPY_ID_LEGACY" != "x" ]; then
Petr Lautrbach b898cb
+      NEW_IDS=`eval "$GET_ID"`
Petr Lautrbach b898cb
+    else
Petr Lautrbach b898cb
+      populate_new_ids 0
Petr Lautrbach b898cb
+    fi
Petr Lautrbach b898cb
     [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | ssh "$@" "
Petr Lautrbach b898cb
 		umask 077 ;
Petr Lautrbach b898cb
 		mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ;
Petr Lautrbach b898cb
diff --git a/contrib/ssh-copy-id.1 b/contrib/ssh-copy-id.1
Petr Lautrbach b898cb
index 67a59e4..df7ce16 100644
Petr Lautrbach b898cb
--- a/contrib/ssh-copy-id.1
Petr Lautrbach b898cb
+++ b/contrib/ssh-copy-id.1
Petr Lautrbach b898cb
@@ -180,6 +180,18 @@ should prove enlightening (N.B. the modern approach is to use the
Petr Lautrbach b898cb
 .Fl W
Petr Lautrbach b898cb
 option, rather than
Petr Lautrbach b898cb
 .Xr nc 1 ) .
Petr Lautrbach b898cb
+.Sh ENVIRONMENT
Petr Lautrbach b898cb
+.Bl -tag -width Ds
Petr Lautrbach b898cb
+.Pp
Petr Lautrbach b898cb
+.It Pa SSH_COPY_ID_LEGACY
Petr Lautrbach b898cb
+If the 
Petr Lautrbach b898cb
+.Cm SSH_COPY_ID_LEGACY
Petr Lautrbach b898cb
+environment variable is set, the
Petr Lautrbach b898cb
+.Nm
Petr Lautrbach b898cb
+is run in a legacy mode. In this mode, the 
Petr Lautrbach b898cb
+.Nm
Petr Lautrbach b898cb
+doesn't check an existence of a private key and doesn't do remote checks
Petr Lautrbach b898cb
+of the remote server versions or if public keys are already installed.
Petr Lautrbach b898cb
 .Sh "SEE ALSO"
Petr Lautrbach b898cb
 .Xr ssh 1 ,
Petr Lautrbach b898cb
 .Xr ssh-agent 1 ,