"-v" handling in scp (was Re: add scp path to _PATH_STDPATH)
Ishikawa
ishikawa at yk.rim.or.jp
Tue Mar 6 05:10:49 EST 2001
Hi,
Attached is the cleaned patch.
I have just realized that the 2.5.1p2 has not
solved the PATH issue for scp searched by the sshd daemon
if we choose the default installation:
i.e., ./configure; make ; make install.
Eg. The scp against the local sshd fails since
scp could not be found by the local sshd's built-in path.
(scp is installed into /usr/local/bin/scp.)
Failure:
ishikawa at duron$ ./scp -v -v -v /tmp/t.lst localhost:/tmp/t2.lst
Executing: program /usr/local/bin/ssh host localhost, user (unspecified),
command scp -v -v -v -t /tmp/t2.lst
OpenSSH_2.5.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090581f
debug: Reading configuration data /usr/local/etc/ssh_config
debug: Applying options for *
debug: ssh_connect: getuid 1001 geteuid 0 anon 0
debug: Connecting to localhost [::1] port 22.
rresvport: af=10 Address family not supported by protocol
debug: Connecting to localhost [127.0.0.1] port 22.
debug: Seeding random number generator
debug: Allocated local port 651.
debug: Connection established.
debug: identity file /home/ishikawa/.ssh/identity type 0
debug: identity file /home/ishikawa/.ssh/id_dsa type 3
debug: Remote protocol version 1.5, remote software version OpenSSH_2.5.1p2
debug: match: OpenSSH_2.5.1p2 pat ^OpenSSH
debug: Local version string SSH-1.5-OpenSSH_2.5.1p2
debug: Waiting for server public key.
debug: Received server public key (768 bits) and host key (1024 bits).
debug: Forcing accepting of host key for loopback/localhost.
debug: Seeding random number generator
debug: Encryption type: 3des
debug: Sent encrypted session key.
debug: Installing crc compensation attack detector.
debug: Received encrypted confirmation.
debug: Trying RSA authentication with key 'ishikawa at standard'
debug: Received RSA challenge from server.
Enter passphrase for RSA key 'ishikawa at standard':
Bad passphrase.
debug: Remote: Wrong response to RSA authentication challenge.
debug: Doing password authentication.
ishikawa at localhost's password:
debug: Sending command: scp -v -v -v -t /tmp/t2.lst
debug: Entering interactive session.
bash: scp: command not found
debug: Transferred: stdin 0, stdout 29, stderr 0 bytes in 0.1 seconds
debug: Bytes per second: stdin 0.0, stdout 534.0, stderr 0.0
debug: Exit status 127
lost connection
After reconfiguring with the following configure command line
(since scp is installed into /usr/local/bin by default),
and re-run the daemon locally, scp against the local sshd succeeded.
./configure --with-default-path=/usr/sbin:/sbin:/bin:/usr/bin:/usr/local/bin
However, there was one issue.
I am not sure why.
But I have to hit RETURN to obtain the shell prompt after seeing
the debug message and saw the transfer finish.
Success example, but note the extra RETURN I needed to hit.
ishikawa at duron$ !./scp
./scp -v -v -v /tmp/t.lst localhost:/tmp/t2.lst
Executing: program /usr/local/bin/ssh host localhost, user (unspecified),
command scp -v -v -v -t /tmp/t2.lst
OpenSSH_2.5.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090581f
debug: Reading configuration data /usr/local/etc/ssh_config
debug: Applying options for *
debug: ssh_connect: getuid 1001 geteuid 0 anon 0
debug: Connecting to localhost [::1] port 22.
rresvport: af=10 Address family not supported by protocol
debug: Connecting to localhost [127.0.0.1] port 22.
debug: Seeding random number generator
debug: Allocated local port 970.
debug: Connection established.
debug: identity file /home/ishikawa/.ssh/identity type 0
debug: identity file /home/ishikawa/.ssh/id_dsa type 3
debug: Remote protocol version 1.5, remote software version OpenSSH_2.5.1p2
debug: match: OpenSSH_2.5.1p2 pat ^OpenSSH
debug: Local version string SSH-1.5-OpenSSH_2.5.1p2
debug: Waiting for server public key.
debug: Received server public key (768 bits) and host key (1024 bits).
debug: Forcing accepting of host key for loopback/localhost.
debug: Seeding random number generator
debug: Encryption type: 3des
debug: Sent encrypted session key.
debug: Installing crc compensation attack detector.
debug: Received encrypted confirmation.
debug: Trying RSA authentication with key 'ishikawa at standard'
debug: Received RSA challenge from server.
Enter passphrase for RSA key 'ishikawa at standard':
Bad passphrase.
debug: Remote: Wrong response to RSA authentication challenge.
debug: Doing password authentication.
ishikawa at localhost's password:
debug: Sending command: scp -v -v -v -t /tmp/t2.lst
debug: Entering interactive session.
Sending file modes: C0644 0 t.lst
t.lst 100% |*****************************| 0 --:--
ETAt.lst 100% |*****************************| 0 00:00
ishikawa at duron$ debug: Transferred: stdin 15, stdout 3, stderr 0 bytes in 0.0
seconds
debug: Bytes per second: stdin 321.3, stdout 64.3, stderr 0.0
debug: Exit status 0
<==== HERE I NEEDED TO HIT RETURN or prompt won't
appear. why???
ishikawa at duron$
Another puzzle: where did the output of "-v" verbose messages
from the remote ssh go? (Maybe I should re-phrase
the question to where should they go, or why they should not appear at all.)
I have a suspicion that the extra RETURN necessary may have
something to do with this, but I may be wrong.
Patch: I have not bothered to change the option parsing yet.
===================================================================
RCS file: RCS/scp.c,v
retrieving revision 1.1
diff -c -r1.1 scp.c
*** scp.c 2001/03/04 18:35:17 1.1
--- scp.c 2001/03/05 17:45:52
***************
*** 277,284 ****
ssh_program = xstrdup(optarg);
break;
case 'v':
! verbose_mode = 1;
! break;
case 'q':
showprogress = 0;
break;
--- 277,294 ----
ssh_program = xstrdup(optarg);
break;
case 'v':
! verbose_mode ++; /* for remote */
! if(verbose_mode <= 3)
! addargs("-v"); /* for local ssh */
! if(verbose_mode == 4)
! {
!
! fprintf(stderr,"\nOnly the first three '-v's are honoured
for passing to remote scp. \n");
! fprintf(stderr,"OpenSSH ssh 2.5.1p2 only accepts only up
to three '-v's.\n");
! fprintf(stderr,"The rest is ignored.\n\n");
!
! }
! break;
case 'q':
showprogress = 0;
break;
***************
*** 327,336 ****
if (argc > 2)
targetshouldbedirectory = 1;
remin = remout = -1;
/* Command to be executed on remote system using "ssh". */
(void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s",
! verbose_mode ? " -v" : "",
iamrecursive ? " -r" : "", pflag ? " -p" : "",
targetshouldbedirectory ? " -d" : "");
--- 337,352 ----
if (argc > 2)
targetshouldbedirectory = 1;
+ /* macros to print up to three "-v"s. */
+
+ #define print_verbose(count) \
+ ((count) <= 0 ? "" : ( (count) == 1 ? " -v" : ( (count) == 2 ? " -v -v" \
+ : " -v -v -v" )))
+
remin = remout = -1;
/* Command to be executed on remote system using "ssh". */
(void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s",
! print_verbose(verbose_mode),
iamrecursive ? " -r" : "", pflag ? " -p" : "",
targetshouldbedirectory ? " -d" : "");
***************
*** 404,410 ****
snprintf(bp, len,
"%s%s -x -o'FallBackToRsh no' -n "
"-l %s %s %s %s '%s%s%s:%s'",
! ssh_program, verbose_mode ? " -v" : "",
suser, host, cmd, src,
tuser ? tuser : "", tuser ? "@" : "",
thost, targ);
--- 420,429 ----
snprintf(bp, len,
"%s%s -x -o'FallBackToRsh no' -n "
"-l %s %s %s %s '%s%s%s:%s'",
! ssh_program,
!
! print_verbose(verbose_mode),
!
suser, host, cmd, src,
tuser ? tuser : "", tuser ? "@" : "",
thost, targ);
***************
*** 413,419 ****
snprintf(bp, len,
"exec %s%s -x -o'FallBackToRsh no' -n %s "
"%s %s '%s%s%s:%s'",
! ssh_program, verbose_mode ? " -v" : "",
host, cmd, src,
tuser ? tuser : "", tuser ? "@" : "",
thost, targ);
--- 432,441 ----
snprintf(bp, len,
"exec %s%s -x -o'FallBackToRsh no' -n %s "
"%s %s '%s%s%s:%s'",
! ssh_program,
!
! print_verbose(verbose_mode),
!
host, cmd, src,
tuser ? tuser : "", tuser ? "@" : "",
thost, targ);
***************
*** 1263,1265 ****
--- 1285,1288 ----
args.list[args.num++] = xstrdup(buf);
args.list[args.num] = NULL;
}
+
More information about the openssh-unix-dev
mailing list