[openssh-commits] [openssh] 09/11: if -s & -p specified, mention 'sftp -P' on success

git+noreply at mindrot.org git+noreply at mindrot.org
Thu May 25 18:26:21 AEST 2023


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

commit 9de79df66d1430d290fab670bb4b18612875e518
Author: Philip Hands <phil at hands.com>
Date:   Wed May 24 11:45:43 2023 +0200

    if -s & -p specified, mention 'sftp -P' on success
    
    This was inspired by this:
     https://github.com/openssh/openssh-portable/pull/321
    but I thought that it was better to not do the sed patching.
    
    BTW the reason one can get away with using $SSH_OPTS throughout, despite
    the lowercase -p in there, even if sftp is in use, is that the sftp call
    is using the already-established ssh master connection, so the port was
    passed to the earlier ssh.
    
    SSH-Copy-ID-Upstream: 1c124d9bfafdbe28a00b683367ebf5750ce12eb2
---
 contrib/ssh-copy-id | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id
index f5ec6892..fcf0edba 100644
--- a/contrib/ssh-copy-id
+++ b/contrib/ssh-copy-id
@@ -126,7 +126,7 @@ do
       SEEN_OPT_I="yes"
       use_id_file "${OPTARG:-$DEFAULT_PUB_ID_FILE}"
       ;;
-    o|p|F)
+    o|F)
       SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }-$OPT '$(quote "${OPTARG}")'"
       ;;
     f)
@@ -135,6 +135,9 @@ do
     n)
       DRY_RUN=1
       ;;
+    p)
+      SSH_PORT=${OPTARG}
+      ;;
     s)
       SFTP=sftp
       ;;
@@ -163,7 +166,7 @@ fi
 
 USER_HOST="$*"
 # tack the hostname onto SSH_OPTS
-SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }'$(quote "$USER_HOST")'"
+SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }${SSH_PORT:+-p $SSH_PORT }'$(quote "$USER_HOST")'"
 # and populate "$@" for later use (only way to get proper quoting of options)
 eval set -- "$SSH_OPTS"
 
@@ -370,11 +373,12 @@ if [ "$DRY_RUN" ] ; then
 	=-=-=-=-=-=-=-=
 	EOF
 else
+  [ -z "$SFTP" ] || PORT_OPT=P
   cat <<-EOF
 
 	Number of key(s) added: $ADDED
 
-	Now try logging into the machine, with:   "${SFTP:-ssh} $SSH_OPTS"
+	Now try logging into the machine, with:   "${SFTP:-ssh}${SSH_PORT:+ -${PORT_OPT:-p} '$SSH_PORT'} ${SSH_OPTS}"
 	and check to make sure that only the key(s) you wanted were added.
 
 	EOF

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list