vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
Jakub Jelen 86f52d
From 1a52b2d612b1d0c2a15dfcdc8da560704909ec72 Mon Sep 17 00:00:00 2001
Jakub Jelen 86f52d
From: Philip Hands <phil@hands.com>
Jakub Jelen 86f52d
Date: Sat, 27 Jul 2013 14:16:52 +0100
Jakub Jelen 86f52d
Subject: [PATCH] echo --> printf "%s: ERROR... (for consistency)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
---
Jakub Jelen 86f52d
 ssh-copy-id | 2 +-
Jakub Jelen 86f52d
 1 file changed, 1 insertion(+), 1 deletion(-)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
index ae88e99..516b87f 100755
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
@@ -200,7 +200,7 @@ populate_new_ids() {
Jakub Jelen 86f52d
   umask 0177
Jakub Jelen 86f52d
   local L_TMP_ID_FILE=$(mktemp ~/.ssh/ssh-copy-id_id.XXXXXXXXXX)
Jakub Jelen 86f52d
   if test $? -ne 0 || test "x$L_TMP_ID_FILE" = "x" ; then
Jakub Jelen 86f52d
-    echo "mktemp failed" 1>&2
Jakub Jelen 86f52d
+    printf '%s: ERROR: mktemp failed\n' "$0" >&2
Jakub Jelen 86f52d
     exit 1
Jakub Jelen 86f52d
   fi
Jakub Jelen 86f52d
   trap "rm -f $L_TMP_ID_FILE ${L_TMP_ID_FILE}.pub" EXIT TERM INT QUIT
Jakub Jelen 86f52d
-- 
Jakub Jelen 86f52d
1.9.1
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
From baebbb9e18e4a1af7554d939710eacb665a24b68 Mon Sep 17 00:00:00 2001
Jakub Jelen 86f52d
From: Philip Hands <phil@hands.com>
Jakub Jelen 86f52d
Date: Wed, 25 Nov 2015 17:05:39 +0100
Jakub Jelen 86f52d
Subject: [PATCH] Deal with remote user shell being e.g. tcsh (fixes: 2206)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
as suggested by Jakub Jelen <jjelen@redhat.com>
Jakub Jelen 86f52d
---
Jakub Jelen 86f52d
 ssh-copy-id | 6 ++----
Jakub Jelen 86f52d
 1 file changed, 2 insertions(+), 4 deletions(-)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
index 516b87f..6a0447a 100755
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
@@ -269,10 +269,8 @@ case "$REMOTE_VERSION" in
Jakub Jelen 86f52d
   *)
Jakub Jelen 86f52d
     # Assuming that the remote host treats ~/.ssh/authorized_keys as one might expect
Jakub Jelen 86f52d
     populate_new_ids 0
Jakub Jelen 86f52d
-    [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | ssh "$@" "
Jakub Jelen 86f52d
-		umask 077 ;
Jakub Jelen 86f52d
-		mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ;
Jakub Jelen 86f52d
-		if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi" \
Jakub Jelen 86f52d
+    [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | \
Jakub Jelen 86f52d
+      ssh "$@" "exec sh -c 'umask 077 ; mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ; if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi'" \
Jakub Jelen 86f52d
       || exit 1
Jakub Jelen 86f52d
     ADDED=$(printf '%s\n' "$NEW_IDS" | wc -l)
Jakub Jelen 86f52d
     ;;
Jakub Jelen 86f52d
-- 
Jakub Jelen 86f52d
1.9.1
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
From 35f05e39cda8670b3f6797330a3e521fda509a4c Mon Sep 17 00:00:00 2001
Jakub Jelen 86f52d
From: Philip Hands <phil@hands.com>
Jakub Jelen 86f52d
Date: Wed, 25 Nov 2015 21:14:00 +0100
Jakub Jelen 86f52d
Subject: [PATCH] set LogLevel to ensure that it's not set to 'None' (closes:
Jakub Jelen 86f52d
 2214)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
As pointed out by  Sami Haahtinen <sami@badwolf.fi>,
Jakub Jelen 86f52d
the LogLevel is set to 'None' we'll not get the
Jakub Jelen 86f52d
Permission Denied we're looking for.
Jakub Jelen 86f52d
---
Jakub Jelen 86f52d
 ssh-copy-id | 1 +
Jakub Jelen 86f52d
 1 file changed, 1 insertion(+)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
index 6a0447a..70d3866 100755
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
@@ -215,6 +215,7 @@ populate_new_ids() {
Jakub Jelen 86f52d
         # The point being that if file based, ssh needs the private key, which it cannot
Jakub Jelen 86f52d
         # find if only given the contents of the .pub file in an unrelated tmpfile
Jakub Jelen 86f52d
         ssh -i "${PRIV_ID_FILE:-$L_TMP_ID_FILE}" \
Jakub Jelen 86f52d
+            -o LogLevel=INFO \
Jakub Jelen 86f52d
             -o PreferredAuthentications=publickey \
Jakub Jelen 86f52d
             -o IdentitiesOnly=yes "$@" exit 2>$L_TMP_ID_FILE.stderr 
Jakub Jelen 86f52d
         if [ "$?" = "$L_SUCCESS" ] ; then
Jakub Jelen 86f52d
-- 
Jakub Jelen 86f52d
1.9.1
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
From e129c91dc474d73671304403fafda785df440105 Mon Sep 17 00:00:00 2001
Jakub Jelen 86f52d
From: Philip Hands <phil@hands.com>
Jakub Jelen 86f52d
Date: Wed, 25 Nov 2015 22:30:43 +0100
Jakub Jelen 86f52d
Subject: [PATCH] set ControlPath=none (closes: 2488)
Jakub Jelen 86f52d
MIME-Version: 1.0
Jakub Jelen 86f52d
Content-Type: text/plain; charset=utf8
Jakub Jelen 86f52d
Content-Transfer-Encoding: 8bit
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Thanks to  Salvador Fandiño <sfandino@yahoo.com> for the patch
Jakub Jelen 86f52d
This seems to be the same problem as described in 2195
Jakub Jelen 86f52d
---
Jakub Jelen 86f52d
 ssh-copy-id | 3 ++-
Jakub Jelen 86f52d
 1 file changed, 2 insertions(+), 1 deletion(-)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
index 70d3866..7df7fad 100755
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
@@ -215,6 +215,7 @@ populate_new_ids() {
Jakub Jelen 86f52d
         # The point being that if file based, ssh needs the private key, which it cannot
Jakub Jelen 86f52d
         # find if only given the contents of the .pub file in an unrelated tmpfile
Jakub Jelen 86f52d
         ssh -i "${PRIV_ID_FILE:-$L_TMP_ID_FILE}" \
Jakub Jelen 86f52d
+            -o ControlPath=none \
Jakub Jelen 86f52d
             -o LogLevel=INFO \
Jakub Jelen 86f52d
             -o PreferredAuthentications=publickey \
Jakub Jelen 86f52d
             -o IdentitiesOnly=yes "$@" exit 2>$L_TMP_ID_FILE.stderr 
Jakub Jelen 86f52d
@@ -244,7 +245,7 @@ populate_new_ids() {
Jakub Jelen 86f52d
   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
Jakub Jelen 86f52d
 }
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
-REMOTE_VERSION=$(ssh -v -o PreferredAuthentications=',' "$@" 2>&1 |
Jakub Jelen 86f52d
+REMOTE_VERSION=$(ssh -v -o PreferredAuthentications=',' -o ControlPath=none "$@" 2>&1 |
Jakub Jelen 86f52d
                  sed -ne 's/.*remote software version //p')
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
 case "$REMOTE_VERSION" in
Jakub Jelen 86f52d
-- 
Jakub Jelen 86f52d
1.9.1
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
From 6fa6f1e3dbec32636e77d01228ceecfa3851c7e8 Mon Sep 17 00:00:00 2001
Jakub Jelen 86f52d
From: Philip Hands <phil@hands.com>
Jakub Jelen 86f52d
Date: Wed, 25 Nov 2015 23:24:13 +0100
Jakub Jelen 86f52d
Subject: [PATCH] add -f (forced) option to install keys unconditionally
Jakub Jelen 86f52d
 (closes: 2110)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Thanks for the patch from Petr Lautrbach <plautrba@redhat.com>
Jakub Jelen 86f52d
which inspired this.
Jakub Jelen 86f52d
---
Jakub Jelen 86f52d
 ssh-copy-id   | 15 +++++++++++++--
Jakub Jelen 86f52d
 ssh-copy-id.1 |  5 +++++
Jakub Jelen 86f52d
 2 files changed, 18 insertions(+), 2 deletions(-)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
index 7df7fad..3121171 100755
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
@@ -59,7 +59,10 @@ fi
Jakub Jelen 86f52d
 DEFAULT_PUB_ID_FILE=$(ls -t ${HOME}/.ssh/id*.pub 2>/dev/null | grep -v -- '-cert.pub$' | head -n 1)
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
 usage () {
Jakub Jelen 86f52d
-  printf 'Usage: %s [-h|-?|-n] [-i [identity_file]] [-p port] [[-o <ssh -o options>] ...] [user@]hostname\n' "$0" >&2
Jakub Jelen 86f52d
+  printf 'Usage: %s [-h|-?|-f|-n] [-i [identity_file]] [-p port] [[-o <ssh -o options>] ...] [user@]hostname\n' "$0" >&2
Jakub Jelen 86f52d
+  printf '\t-f: force mode -- copy keys without trying to check if they are already installed\n' >&2
Jakub Jelen 86f52d
+  printf '\t-n: dry run    -- no keys are actually copied\n' >&2
Jakub Jelen 86f52d
+  printf '\t-h|-?: print this help\n' >&2
Jakub Jelen 86f52d
   exit 1
Jakub Jelen 86f52d
 }
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
@@ -121,7 +124,7 @@ do
Jakub Jelen 86f52d
       }
Jakub Jelen 86f52d
       shift
Jakub Jelen 86f52d
       ;;
Jakub Jelen 86f52d
-    -n|-h|-\?)
Jakub Jelen 86f52d
+    -f|-n|-h|-\?)
Jakub Jelen 86f52d
       OPT="$1"
Jakub Jelen 86f52d
       OPTARG=
Jakub Jelen 86f52d
       shift
Jakub Jelen 86f52d
@@ -154,6 +157,9 @@ do
Jakub Jelen 86f52d
     -o|-p)
Jakub Jelen 86f52d
       SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }$OPT '$(quote "$OPTARG")'"
Jakub Jelen 86f52d
       ;;
Jakub Jelen 86f52d
+    -f)
Jakub Jelen 86f52d
+      FORCED=1
Jakub Jelen 86f52d
+      ;;
Jakub Jelen 86f52d
     -n)
Jakub Jelen 86f52d
       DRY_RUN=1
Jakub Jelen 86f52d
       ;;
Jakub Jelen 86f52d
@@ -194,6 +200,11 @@ fi
Jakub Jelen 86f52d
 populate_new_ids() {
Jakub Jelen 86f52d
   local L_SUCCESS="$1"
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
+  if [ "$FORCED" ] ; then
Jakub Jelen 86f52d
+    NEW_IDS=$(eval $GET_ID)
Jakub Jelen 86f52d
+    return
Jakub Jelen 86f52d
+  fi
Jakub Jelen 86f52d
+
Jakub Jelen 86f52d
   # repopulate "$@" inside this function 
Jakub Jelen 86f52d
   eval set -- "$SSH_OPTS"
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id.1 $1/contrib/ssh-copy-id.1
Jakub Jelen 86f52d
index 67a59e4..8850cce 100644
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id.1
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id.1
Jakub Jelen 86f52d
@@ -29,6 +29,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Jakub Jelen 86f52d
 .Nd use locally available keys to authorise logins on a remote machine
Jakub Jelen 86f52d
 .Sh SYNOPSIS
Jakub Jelen 86f52d
 .Nm
Jakub Jelen 86f52d
+.Op Fl f
Jakub Jelen 86f52d
 .Op Fl n
Jakub Jelen 86f52d
 .Op Fl i Op Ar identity_file
Jakub Jelen 86f52d
 .Op Fl p Ar port
Jakub Jelen 86f52d
@@ -76,6 +77,10 @@ is used.
Jakub Jelen 86f52d
 Note that this can be used to ensure that the keys copied have the
Jakub Jelen 86f52d
 comment one prefers and/or extra options applied, by ensuring that the
Jakub Jelen 86f52d
 key file has these set as preferred before the copy is attempted.
Jakub Jelen 86f52d
+.It Fl f
Jakub Jelen 86f52d
+Forced mode: doesn't check if the keys are present on the remote server.
Jakub Jelen 86f52d
+This means that it does not need the private key.  Of course, this can result
Jakub Jelen 86f52d
+in more than one copy of the key being installed on the remote system.
Jakub Jelen 86f52d
 .It Fl n
Jakub Jelen 86f52d
 do a dry-run.  Instead of installing keys on the remote system simply
Jakub Jelen 86f52d
 prints the key(s) that would have been installed.
Jakub Jelen 86f52d
-- 
Jakub Jelen 86f52d
1.9.1
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
From ab185eea5a03cdd846c909d83e5dd0a07a44fb54 Mon Sep 17 00:00:00 2001
Jakub Jelen 86f52d
From: Philip Hands <phil@hands.com>
Jakub Jelen 86f52d
Date: Wed, 25 Nov 2015 23:47:06 +0100
Jakub Jelen 86f52d
Subject: [PATCH] deal with #2331 by suggesting the use of the -f option
Jakub Jelen 86f52d
Jakub Jelen 86f52d
---
Jakub Jelen 86f52d
 ssh-copy-id | 3 ++-
Jakub Jelen 86f52d
 1 file changed, 2 insertions(+), 1 deletion(-)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
index 3121171..8666cea 100755
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
@@ -250,7 +250,8 @@ populate_new_ids() {
Jakub Jelen 86f52d
     exit 1
Jakub Jelen 86f52d
   fi
Jakub Jelen 86f52d
   if [ -z "$NEW_IDS" ] ; then
Jakub Jelen 86f52d
-    printf '\n%s: WARNING: All keys were skipped because they already exist on the remote system.\n\n' "$0" >&2
Jakub Jelen 86f52d
+    printf '\n%s: WARNING: All keys were skipped because they already exist on the remote system.\n' "$0" >&2
Jakub Jelen 86f52d
+    printf '\t\t(if you think this is a mistake, you may want to use -f option)\n\n' "$0" >&2
Jakub Jelen 86f52d
     exit 0
Jakub Jelen 86f52d
   fi
Jakub Jelen 86f52d
   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
Jakub Jelen 86f52d
-- 
Jakub Jelen 86f52d
1.9.1
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
From de78897ada50ed12f4b0c9faa6e935ce82ee49a6 Mon Sep 17 00:00:00 2001
Jakub Jelen 86f52d
From: Philip Hands <phil@hands.com>
Jakub Jelen 86f52d
Date: Thu, 26 Nov 2015 00:25:56 +0100
Jakub Jelen 86f52d
Subject: [PATCH] handle keys with missing trailing newline (closes: 2350)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
---
Jakub Jelen 86f52d
 ssh-copy-id | 2 +-
Jakub Jelen 86f52d
 1 file changed, 1 insertion(+), 1 deletion(-)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
index 8666cea..362b49b 100755
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
@@ -218,7 +218,7 @@ populate_new_ids() {
Jakub Jelen 86f52d
   printf '%s: INFO: attempting to log in with the new key(s), to filter out any that are already installed\n' "$0" >&2
Jakub Jelen 86f52d
   NEW_IDS=$(
Jakub Jelen 86f52d
     eval $GET_ID | {
Jakub Jelen 86f52d
-      while read ID ; do
Jakub Jelen 86f52d
+      while read ID || [ "$ID" ] ; do
Jakub Jelen 86f52d
         printf '%s\n' "$ID" > $L_TMP_ID_FILE
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
         # the next line assumes $PRIV_ID_FILE only set if using a single id file - this
Jakub Jelen 86f52d
-- 
Jakub Jelen 86f52d
1.9.1
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
From 6b903ab99a3f0107bb0dbde748a4372033bab00c Mon Sep 17 00:00:00 2001
Jakub Jelen 86f52d
From: Philip Hands <phil@hands.com>
Jakub Jelen 86f52d
Date: Thu, 26 Nov 2015 00:36:09 +0100
Jakub Jelen 86f52d
Subject: [PATCH] add a cd to ensure we're in the remote's home directory
Jakub Jelen 86f52d
 (closes: 2349)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
---
Jakub Jelen 86f52d
 ssh-copy-id | 2 +-
Jakub Jelen 86f52d
 1 file changed, 1 insertion(+), 1 deletion(-)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
index 362b49b..2932936 100755
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
@@ -284,7 +284,7 @@ case "$REMOTE_VERSION" in
Jakub Jelen 86f52d
     # Assuming that the remote host treats ~/.ssh/authorized_keys as one might expect
Jakub Jelen 86f52d
     populate_new_ids 0
Jakub Jelen 86f52d
     [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | \
Jakub Jelen 86f52d
-      ssh "$@" "exec sh -c 'umask 077 ; mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ; if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi'" \
Jakub Jelen 86f52d
+      ssh "$@" "exec sh -c 'cd ; umask 077 ; mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ; if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi'" \
Jakub Jelen 86f52d
       || exit 1
Jakub Jelen 86f52d
     ADDED=$(printf '%s\n' "$NEW_IDS" | wc -l)
Jakub Jelen 86f52d
     ;;
Jakub Jelen 86f52d
-- 
Jakub Jelen 86f52d
1.9.1
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
From 441892cbf4ff96fd96908582b8170f51890b5deb Mon Sep 17 00:00:00 2001
Jakub Jelen 86f52d
From: Philip Hands <phil@hands.com>
Jakub Jelen 86f52d
Date: Sat, 28 Nov 2015 14:42:36 +0100
Jakub Jelen 86f52d
Subject: [PATCH] add comment about why the ugly one-line remote command is as
Jakub Jelen 86f52d
 it is
Jakub Jelen 86f52d
Jakub Jelen 86f52d
In case anyone looks here for the details:
Jakub Jelen 86f52d
 * tcsh doesn't support multi-line strings,
Jakub Jelen 86f52d
   which is why it's a one-liner.
Jakub Jelen 86f52d
 * tcsh doesn't do 2>&1, and fish doesn't do
Jakub Jelen 86f52d
   'command || command' which is why we're runnig this under
Jakub Jelen 86f52d
   sh (which is very likely to be a POSIX shell on any vaguely
Jakub Jelen 86f52d
   Unix-like system)
Jakub Jelen 86f52d
 * The 'cd' is there to make sure we're in the home dir, because
Jakub Jelen 86f52d
   there was a bug report about having a cd in ~/.bashrc that resulted
Jakub Jelen 86f52d
   in a .ssh being created elsewhere.
Jakub Jelen 86f52d
 * the 'exec' ensures that we're not relying on anything beyond the
Jakub Jelen 86f52d
   (hopefully POSIX) shell that's available as 'sh' on the remote system
Jakub Jelen 86f52d
---
Jakub Jelen 86f52d
 ssh-copy-id | 1 +
Jakub Jelen 86f52d
 1 file changed, 1 insertion(+)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
index 2932936..04c03eb 100755
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
@@ -283,6 +283,7 @@ case "$REMOTE_VERSION" in
Jakub Jelen 86f52d
   *)
Jakub Jelen 86f52d
     # Assuming that the remote host treats ~/.ssh/authorized_keys as one might expect
Jakub Jelen 86f52d
     populate_new_ids 0
Jakub Jelen 86f52d
+    # in ssh below - to defend against quirky remote shells: use 'exec sh -c' to get POSIX; 'cd' to be at $HOME; and all on one line, because tcsh.
Jakub Jelen 86f52d
     [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | \
Jakub Jelen 86f52d
       ssh "$@" "exec sh -c 'cd ; umask 077 ; mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ; if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi'" \
Jakub Jelen 86f52d
       || exit 1
Jakub Jelen 86f52d
-- 
Jakub Jelen 86f52d
1.9.1
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
From 8b59b122d321b97badd15c41e1a22863aa922a02 Mon Sep 17 00:00:00 2001
Jakub Jelen 86f52d
From: Philip Hands <phil@hands.com>
Jakub Jelen 86f52d
Date: Sat, 28 Nov 2015 14:46:47 +0100
Jakub Jelen 86f52d
Subject: [PATCH] with '-f' there's no need to have access to the private key
Jakub Jelen 86f52d
Jakub Jelen 86f52d
---
Jakub Jelen 86f52d
 ssh-copy-id | 2 +-
Jakub Jelen 86f52d
 1 file changed, 1 insertion(+), 1 deletion(-)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
index 04c03eb..d3ff83b 100755
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
@@ -80,7 +80,7 @@ use_id_file() {
Jakub Jelen 86f52d
     PUB_ID_FILE="$L_ID_FILE.pub"
Jakub Jelen 86f52d
   fi
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
-  PRIV_ID_FILE=$(dirname "$PUB_ID_FILE")/$(basename "$PUB_ID_FILE" .pub)
Jakub Jelen 86f52d
+  [ "$FORCED" ] || PRIV_ID_FILE=$(dirname "$PUB_ID_FILE")/$(basename "$PUB_ID_FILE" .pub)
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
   # check that the files are readable
Jakub Jelen 86f52d
   for f in $PUB_ID_FILE $PRIV_ID_FILE ; do
Jakub Jelen 86f52d
-- 
Jakub Jelen 86f52d
1.9.1
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
From 1b931894de0614099255244be789ad097fd0948a Mon Sep 17 00:00:00 2001
Jakub Jelen 86f52d
From: Philip Hands <phil@hands.com>
Jakub Jelen 86f52d
Date: Sat, 28 Nov 2015 14:47:35 +0100
Jakub Jelen 86f52d
Subject: [PATCH] if the private key is missing, point out that '-f' might be
Jakub Jelen 86f52d
 what's needed
Jakub Jelen 86f52d
Jakub Jelen 86f52d
---
Jakub Jelen 86f52d
 ssh-copy-id | 4 +++-
Jakub Jelen 86f52d
 1 file changed, 3 insertions(+), 1 deletion(-)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
index d3ff83b..f0b01aa 100755
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
@@ -85,7 +85,9 @@ use_id_file() {
Jakub Jelen 86f52d
   # check that the files are readable
Jakub Jelen 86f52d
   for f in $PUB_ID_FILE $PRIV_ID_FILE ; do
Jakub Jelen 86f52d
     ErrMSG=$( { : < $f ; } 2>&1 ) || {
Jakub Jelen 86f52d
-      printf "\n%s: ERROR: failed to open ID file '%s': %s\n\n" "$0" "$f" "$(printf "%s\n" "$ErrMSG" | sed -e 's/.*: *//')"
Jakub Jelen 86f52d
+      local L_PRIVMSG=""
Jakub Jelen 86f52d
+      [ "$f" = "$PRIV_ID_FILE" ] && L_PRIVMSG="	(to install the contents of '$PUB_ID_FILE' anyway, look at the -f option)"
Jakub Jelen 86f52d
+      printf "\n%s: ERROR: failed to open ID file '%s': %s\n" "$0" "$f" "$(printf "%s\n%s\n" "$ErrMSG" "$L_PRIVMSG" | sed -e 's/.*: *//')"
Jakub Jelen 86f52d
       exit 1
Jakub Jelen 86f52d
     }
Jakub Jelen 86f52d
   done
Jakub Jelen 86f52d
-- 
Jakub Jelen 86f52d
1.9.1
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
From fd3e8b115e160a1332773cd8e06a3305d0d680ab Mon Sep 17 00:00:00 2001
Jakub Jelen 86f52d
From: Philip Hands <phil@hands.com>
Jakub Jelen 86f52d
Date: Sat, 28 Nov 2015 21:10:39 +0100
Jakub Jelen 86f52d
Subject: [PATCH] +INFO message to mitigate the surprise described in #2196
Jakub Jelen 86f52d
Jakub Jelen 86f52d
---
Jakub Jelen 86f52d
 ssh-copy-id | 1 +
Jakub Jelen 86f52d
 1 file changed, 1 insertion(+)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
index f0b01aa..994194e 100755
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
@@ -91,6 +91,7 @@ use_id_file() {
Jakub Jelen 86f52d
       exit 1
Jakub Jelen 86f52d
     }
Jakub Jelen 86f52d
   done
Jakub Jelen 86f52d
+  printf '%s: INFO: Source of key(s) to be installed: "%s"\n' "$0" $PUB_ID_FILE >&2
Jakub Jelen 86f52d
   GET_ID="cat \"$PUB_ID_FILE\""
Jakub Jelen 86f52d
 }
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
-- 
Jakub Jelen 86f52d
1.9.1
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen 86f52d
From 783ef08b0a757402aba67313f08f8dbfa9bf85f3 Mon Sep 17 00:00:00 2001
Jakub Jelen 86f52d
From: Philip Hands <phil@hands.com>
Jakub Jelen 86f52d
Date: Mon, 30 Nov 2015 20:46:19 +0100
Jakub Jelen 86f52d
Subject: [PATCH] deal with $HOME and id filenames that include a space
Jakub Jelen 86f52d
Jakub Jelen 86f52d
---
Jakub Jelen 86f52d
 ssh-copy-id | 15 ++++++++-------
Jakub Jelen 86f52d
 1 file changed, 8 insertions(+), 7 deletions(-)
Jakub Jelen 86f52d
Jakub Jelen 86f52d
diff --git $1/contrib/ssh-copy-id $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
index 994194e..afde8b1 100755
Jakub Jelen 86f52d
--- $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
+++ $1/contrib/ssh-copy-id
Jakub Jelen 86f52d
@@ -56,7 +56,7 @@ then
Jakub Jelen 86f52d
   fi
Jakub Jelen 86f52d
 fi
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
-DEFAULT_PUB_ID_FILE=$(ls -t ${HOME}/.ssh/id*.pub 2>/dev/null | grep -v -- '-cert.pub$' | head -n 1)
Jakub Jelen 86f52d
+DEFAULT_PUB_ID_FILE="$HOME/$(cd "$HOME" ; ls -t .ssh/id*.pub 2>/dev/null | grep -v -- '-cert.pub$' | head -n 1)"
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
 usage () {
Jakub Jelen 86f52d
   printf 'Usage: %s [-h|-?|-f|-n] [-i [identity_file]] [-p port] [[-o <ssh -o options>] ...] [user@]hostname\n' "$0" >&2
Jakub Jelen 86f52d
@@ -83,15 +83,15 @@ use_id_file() {
Jakub Jelen 86f52d
   [ "$FORCED" ] || PRIV_ID_FILE=$(dirname "$PUB_ID_FILE")/$(basename "$PUB_ID_FILE" .pub)
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
   # check that the files are readable
Jakub Jelen 86f52d
-  for f in $PUB_ID_FILE $PRIV_ID_FILE ; do
Jakub Jelen 86f52d
-    ErrMSG=$( { : < $f ; } 2>&1 ) || {
Jakub Jelen 86f52d
+  for f in "$PUB_ID_FILE" ${PRIV_ID_FILE:+"$PRIV_ID_FILE"} ; do
Jakub Jelen 86f52d
+    ErrMSG=$( { : < "$f" ; } 2>&1 ) || {
Jakub Jelen 86f52d
       local L_PRIVMSG=""
Jakub Jelen 86f52d
       [ "$f" = "$PRIV_ID_FILE" ] && L_PRIVMSG="	(to install the contents of '$PUB_ID_FILE' anyway, look at the -f option)"
Jakub Jelen 86f52d
       printf "\n%s: ERROR: failed to open ID file '%s': %s\n" "$0" "$f" "$(printf "%s\n%s\n" "$ErrMSG" "$L_PRIVMSG" | sed -e 's/.*: *//')"
Jakub Jelen 86f52d
       exit 1
Jakub Jelen 86f52d
     }
Jakub Jelen 86f52d
   done
Jakub Jelen 86f52d
-  printf '%s: INFO: Source of key(s) to be installed: "%s"\n' "$0" $PUB_ID_FILE >&2
Jakub Jelen 86f52d
+  printf '%s: INFO: Source of key(s) to be installed: "%s"\n' "$0" "$PUB_ID_FILE" >&2
Jakub Jelen 86f52d
   GET_ID="cat \"$PUB_ID_FILE\""
Jakub Jelen 86f52d
 }
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
@@ -217,12 +217,13 @@ populate_new_ids() {
Jakub Jelen 86f52d
     printf '%s: ERROR: mktemp failed\n' "$0" >&2
Jakub Jelen 86f52d
     exit 1
Jakub Jelen 86f52d
   fi
Jakub Jelen 86f52d
-  trap "rm -f $L_TMP_ID_FILE ${L_TMP_ID_FILE}.pub" EXIT TERM INT QUIT
Jakub Jelen 86f52d
+  local L_CLEANUP="rm -f \"$L_TMP_ID_FILE\" \"${L_TMP_ID_FILE}.stderr\""
Jakub Jelen 86f52d
+  trap "$L_CLEANUP" EXIT TERM INT QUIT
Jakub Jelen 86f52d
   printf '%s: INFO: attempting to log in with the new key(s), to filter out any that are already installed\n' "$0" >&2
Jakub Jelen 86f52d
   NEW_IDS=$(
Jakub Jelen 86f52d
     eval $GET_ID | {
Jakub Jelen 86f52d
       while read ID || [ "$ID" ] ; do
Jakub Jelen 86f52d
-        printf '%s\n' "$ID" > $L_TMP_ID_FILE
Jakub Jelen 86f52d
+        printf '%s\n' "$ID" > "$L_TMP_ID_FILE"
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
         # the next line assumes $PRIV_ID_FILE only set if using a single id file - this
Jakub Jelen 86f52d
         # assumption will break if we implement the possibility of multiple -i options.
Jakub Jelen 86f52d
@@ -246,7 +247,7 @@ populate_new_ids() {
Jakub Jelen 86f52d
       done
Jakub Jelen 86f52d
     }
Jakub Jelen 86f52d
   )
Jakub Jelen 86f52d
-  rm -f $L_TMP_ID_FILE* && trap - EXIT TERM INT QUIT
Jakub Jelen 86f52d
+  eval "$L_CLEANUP" && trap - EXIT TERM INT QUIT
Jakub Jelen 86f52d
 
Jakub Jelen 86f52d
   if expr "$NEW_IDS" : "^ERROR: " >/dev/null ; then
Jakub Jelen 86f52d
     printf '\n%s: %s\n\n' "$0" "$NEW_IDS" >&2
Jakub Jelen 86f52d
-- 
Jakub Jelen 86f52d
1.9.1
Jakub Jelen 86f52d
Jakub Jelen 86f52d
Jakub Jelen c9e7e7
diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id
Jakub Jelen c9e7e7
index afde8b1..cd52764 100644
Jakub Jelen c9e7e7
--- a/contrib/ssh-copy-id
Jakub Jelen c9e7e7
+++ b/contrib/ssh-copy-id
Jakub Jelen e1b19d
@@ -99,6 +99,8 @@ if [ -n "$SSH_AUTH_SOCK" ] && ssh-add -L >/dev/null 2>&1 ; then
Jakub Jelen e1b19d
   GET_ID="ssh-add -L"
Jakub Jelen e1b19d
 fi
Jakub Jelen c9e7e7
 
Jakub Jelen e1b19d
+[ "x$SSH_COPY_ID_LEGACY" != "x" ] && FORCED=1
Jakub Jelen e1b19d
+
Jakub Jelen e1b19d
 while test "$#" -gt 0
Jakub Jelen e1b19d
 do
Jakub Jelen e1b19d
   [ "${SEEN_OPT_I}" ] && expr "$1" : "[-]i" >/dev/null && {
Jakub Jelen c9e7e7
diff --git a/contrib/ssh-copy-id.1 b/contrib/ssh-copy-id.1
Jakub Jelen c9e7e7
index 8850cce..62f112d 100644
Jakub Jelen c9e7e7
--- a/contrib/ssh-copy-id.1
Jakub Jelen c9e7e7
+++ b/contrib/ssh-copy-id.1
Jakub Jelen c9e7e7
@@ -185,6 +185,22 @@ should prove enlightening (N.B. the modern approach is to use the
Jakub Jelen c9e7e7
 .Fl W
Jakub Jelen c9e7e7
 option, rather than
Jakub Jelen c9e7e7
 .Xr nc 1 ) .
Jakub Jelen c9e7e7
+.Sh ENVIRONMENT
Jakub Jelen c9e7e7
+.Bl -tag -width Ds
Jakub Jelen c9e7e7
+.Pp
Jakub Jelen c9e7e7
+.It Pa SSH_COPY_ID_LEGACY
Jakub Jelen c9e7e7
+If the
Jakub Jelen c9e7e7
+.Cm SSH_COPY_ID_LEGACY
Jakub Jelen c9e7e7
+environment variable is set, the
Jakub Jelen c9e7e7
+.Nm
Jakub Jelen c9e7e7
+is run in a legacy mode. In this mode, the
Jakub Jelen c9e7e7
+.Nm
Jakub Jelen c9e7e7
+doesn't check an existence of a private key and doesn't do remote checks
Jakub Jelen c9e7e7
+of the remote server versions or if public keys are already installed
Jakub Jelen c9e7e7
+(equivalent to
Jakub Jelen c9e7e7
+.Fl f
Jakub Jelen c9e7e7
+switch).
Jakub Jelen c9e7e7
+.El
Jakub Jelen c9e7e7
 .Sh "SEE ALSO"
Jakub Jelen c9e7e7
 .Xr ssh 1 ,
Jakub Jelen c9e7e7
 .Xr ssh-agent 1 ,