View | Details | Raw Unified | Return to bug 2110
Collapse All | Expand All

(-)a/contrib/ssh-copy-id (-4 / +16 lines)
Lines 59-65 fi Link Here
59
DEFAULT_PUB_ID_FILE=$(ls -t ${HOME}/.ssh/id*.pub 2>/dev/null | grep -v -- '-cert.pub$' | head -n 1)
59
DEFAULT_PUB_ID_FILE=$(ls -t ${HOME}/.ssh/id*.pub 2>/dev/null | grep -v -- '-cert.pub$' | head -n 1)
60
60
61
usage () {
61
usage () {
62
  printf 'Usage: %s [-h|-?|-n] [-i [identity_file]] [-p port] [[-o <ssh -o options>] ...] [user@]hostname\n' "$0" >&2
62
  printf 'Usage: %s [-h|-?|-l|-n] [-i [identity_file]] [-p port] [[-o <ssh -o options>] ...] [user@]hostname\n' "$0" >&2
63
  exit 1
63
  exit 1
64
}
64
}
65
65
Lines 77-83 use_id_file() { Link Here
77
    PUB_ID_FILE="$L_ID_FILE.pub"
77
    PUB_ID_FILE="$L_ID_FILE.pub"
78
  fi
78
  fi
79
79
80
  PRIV_ID_FILE=$(dirname "$PUB_ID_FILE")/$(basename "$PUB_ID_FILE" .pub)
80
  [ "$LEGACY" ] || PRIV_ID_FILE=$(dirname "$PUB_ID_FILE")/$(basename "$PUB_ID_FILE" .pub)
81
81
82
  # check that the files are readable
82
  # check that the files are readable
83
  for f in $PUB_ID_FILE $PRIV_ID_FILE ; do
83
  for f in $PUB_ID_FILE $PRIV_ID_FILE ; do
Lines 121-126 do Link Here
121
      }
121
      }
122
      shift
122
      shift
123
      ;;
123
      ;;
124
    -l)
125
      OPT="$1"
126
      OPTARG=
127
      shift
128
      ;;
124
    -n|-h|-\?)
129
    -n|-h|-\?)
125
      OPT="$1"
130
      OPT="$1"
126
      OPTARG=
131
      OPTARG=
Lines 154-159 do Link Here
154
    -o|-p)
159
    -o|-p)
155
      SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }$OPT '$(quote "$OPTARG")'"
160
      SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }$OPT '$(quote "$OPTARG")'"
156
      ;;
161
      ;;
162
    -l)
163
      LEGACY=1
164
      ;;
157
    -n)
165
    -n)
158
      DRY_RUN=1
166
      DRY_RUN=1
159
      ;;
167
      ;;
Lines 243-249 populate_new_ids() { Link Here
243
  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
251
  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
244
}
252
}
245
253
246
REMOTE_VERSION=$(ssh -v -o PreferredAuthentications=',' "$@" 2>&1 |
254
[ "$LEGACY" ] || REMOTE_VERSION=$(ssh -v -o PreferredAuthentications=',' "$@" 2>&1 |
247
                 sed -ne 's/.*remote software version //p')
255
                 sed -ne 's/.*remote software version //p')
248
256
249
case "$REMOTE_VERSION" in
257
case "$REMOTE_VERSION" in
Lines 268-274 case "$REMOTE_VERSION" in Link Here
268
    ;;
276
    ;;
269
  *)
277
  *)
270
    # Assuming that the remote host treats ~/.ssh/authorized_keys as one might expect
278
    # Assuming that the remote host treats ~/.ssh/authorized_keys as one might expect
271
    populate_new_ids 0
279
    if [ "$LEGACY" ]; then
280
      NEW_IDS=`eval "$GET_ID"`
281
    else
282
      populate_new_ids 0
283
    fi
272
    [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | ssh "$@" "
284
    [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | ssh "$@" "
273
		umask 077 ;
285
		umask 077 ;
274
		mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ;
286
		mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ;
(-)a/contrib/ssh-copy-id.1 (-1 / +5 lines)
Lines 29-34 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Link Here
29
.Nd use locally available keys to authorise logins on a remote machine
29
.Nd use locally available keys to authorise logins on a remote machine
30
.Sh SYNOPSIS
30
.Sh SYNOPSIS
31
.Nm
31
.Nm
32
.Op Fl l
32
.Op Fl n
33
.Op Fl n
33
.Op Fl i Op Ar identity_file
34
.Op Fl i Op Ar identity_file
34
.Op Fl p Ar port
35
.Op Fl p Ar port
Lines 76-81 is used. Link Here
76
Note that this can be used to ensure that the keys copied have the
77
Note that this can be used to ensure that the keys copied have the
77
comment one prefers and/or extra options applied, by ensuring that the
78
comment one prefers and/or extra options applied, by ensuring that the
78
key file has these set as preferred before the copy is attempted.
79
key file has these set as preferred before the copy is attempted.
80
.It Fl l
81
run in a legacy mode. In this mode, the ssh-copy-id doesn't check an
82
existence of a private key and doesn't do remote checks of the remote
83
server versions or if public keys are already installed.
79
.It Fl n
84
.It Fl n
80
do a dry-run.  Instead of installing keys on the remote system simply
85
do a dry-run.  Instead of installing keys on the remote system simply
81
prints the key(s) that would have been installed.
86
prints the key(s) that would have been installed.
82
- 

Return to bug 2110