SSH/PATH confusion

3 posts / 0 new
Last post
KenH
Offline
Last seen: 9 years 2 weeks ago
Joined: 12.05.2014 - 22:15
SSH/PATH confusion

I have a whole bunch of "identically" configured servers.  I ran into a single instance of a CopSSH failing when trying to scp a file.

The issue turned out to be a second, incompatible executable of scp that was located in the %WINDOWS%\system32 directory.  However after setting OpenSSH to debug mode, I'm stumped as to the reason the systems are behaving differently.

  1. From the system properties, the PATH environment variables are the same on both servers.
  2. Both servers have the same offending scp.exe in system32.
  3. The PATH appears exposed differently on each server and even though /etc/profile has export PATH="/bin:$syspath:$winpath" direct, /bin is missing from being prepended on server 1 but is present on server 2.

Where is the PATH in "Copy environment" coming from since it doesn't appear to be coming from the System Properties control panel environment variables?

 

Renaming the offending \system32\scp.exe solves the problem.  Better would be to make sure that when I ssh/scp, my environment PATH gets set to either only include the cygwin environment or at the very least consistenly prepend /bin as the first-priorty path to search.

DEBUG FROM SERVER #1 (non-working, anonymized)

[root@MASTERSERVER .ssh]# scp foo.txt root@10.1.xx.c1:/tmp
root@10.1.xx.c1's password:
debug1: permanently_set_uid: 1032/545
debug3: Copy environment: ALLUSERSPROFILE=C:\\Documents and Settings\\All Users
debug3: Copy environment: COMPUTERNAME=COMPUTERNAME1
debug3: Copy environment: COMSPEC=C:\\WINNT\\system32\\cmd.exe
debug3: Copy environment: OS=Windows_NT
debug3: Copy environment: PATH=/cygdrive/c/PROGRAM FILES/SUPPORT TOOLS:/cygdrive/c/WINNT/SYSTEM32:/cygdrive/c/WINNT:/cygdrive/c/WINNT/SYSTEM32/WBEM:/cygdrive/c/users/default:/cygdrive/c/sometools/tools/private:/cygdrive/c/sometools/perl:/cygdrive/c/sometools/perl/bin:/cygdrive/c/sometools/exe:/cygdrive/c/Program Files/NTP/bin:/cygdrive/c/Program Files/sourceforge/ipmiutil:/bin
debug3: Copy environment: PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
debug3: Copy environment: SYSTEMDRIVE=C:
debug3: Copy environment: SYSTEMROOT=C:\\WINNT
debug3: Copy environment: WINDIR=C:\\WINNT
debug3: Copy environment: CYGWIN=nontsec binmode
Environment:
  ALLUSERSPROFILE=C:\Documents and Settings\All Users
  COMPUTERNAME=COMPUTERNAME1
  COMSPEC=C:\WINNT\system32\cmd.exe
  OS=Windows_NT
  PATH=/cygdrive/c/PROGRAM FILES/SUPPORT TOOLS:/cygdrive/c/WINNT/SYSTEM32:/cygdrive/c/WINNT:/cygdrive/c/WINNT/SYSTEM32/WBEM:/cygdrive/c/users/default:/cygdrive/c/sometools/tools/private:/cygdrive/c/
  PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
  SYSTEMDRIVE=C:
  SYSTEMROOT=C:\WINNT
  WINDIR=C:\WINNT
  CYGWIN=nontsec binmode
  USER=root
  LOGNAME=root
  HOME=/home/root
  MAIL=/var/spool/mail/root
  SHELL=/bin/bash
  SSH_CLIENT=10.1.xx.xx 36740 22
  SSH_CONNECTION=10.1.xx.xx 36740 10.1.xx.c1 22
SCP-E-UNKNOWN, unknown SCP command -t /tmp

 

DEBUG FROM SERVER #2 (working, anonymized)

[root@MASTERSERVER .ssh]# scp /tmp/ism_hosts.txt root@10.1.xx.c2:/home/
root@10.1.xx.c2's password:
debug1: permanently_set_uid: 1024/545
debug3: Copy environment: ALLUSERSPROFILE=C:\\Documents and Settings\\All Users
debug3: Copy environment: COMPUTERNAME=COMPUTERNAME2
debug3: Copy environment: COMSPEC=C:\\WINNT\\system32\\cmd.exe
debug3: Copy environment: OS=Windows_NT
debug3: Copy environment: PATH=/bin:/cygdrive/c/WINNT/system32:/cygdrive/c/WINNT:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/bin
debug3: Copy environment: PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
debug3: Copy environment: SYSTEMDRIVE=C:
debug3: Copy environment: SYSTEMROOT=C:\\WINNT
debug3: Copy environment: WINDIR=C:\\WINNT
debug3: Copy environment: CYGWIN=nontsec binmode
Environment:
  ALLUSERSPROFILE=C:\Documents and Settings\All Users
  COMPUTERNAME=COMPUTERNAME2
  COMSPEC=C:\WINNT\system32\cmd.exe
  OS=Windows_NT
  PATH=/bin:/cygdrive/c/WINNT/system32:/cygdrive/c/WINNT:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/bin
  PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
  SYSTEMDRIVE=C:
  SYSTEMROOT=C:\WINNT
  WINDIR=C:\WINNT
  CYGWIN=nontsec binmode
  USER=root
  LOGNAME=root
  HOME=/home/root
  MAIL=/var/spool/mail/root
  SHELL=/bin/bash
  SSH_CLIENT=10.1.xx.xx 42869 22
  SSH_CONNECTION=10.1.xx.xx 42869 10.1.xx.c2 22
foo.txt

itefix
Offline
Last seen: 3 days 6 hours ago
Joined: 01.05.2008 - 21:33
Path values come initially

Path values come initially from the settings in the file etc/profile which is run every time bash is initiated:

....
syspath=`/bin/cygpath -S`
winpath=`/bin/cygpath -W`
export PATH="/bin:$syspath:$winpath"
export TERM=cygwin
umask 027
....

Path values

KenH
Offline
Last seen: 9 years 2 weeks ago
Joined: 12.05.2014 - 22:15
I'll check what cygpath -S

I'll check what cygpath -S and -W are returning on those two systems, however that doesn't explain why on system #1, /bin should be at the front of the path but is missing.

PATH=/cygdrive/c/PROGRAM FILES/SUPPORT TOOLS:/cygdrive/c/WINNT/SYSTEM32:/cygdrive/c/WINNT:/cygdrive/c/WINNT/SYSTEM32/WBEM:/cygdrive/c/users/default:/cygdrive/c/sometools/tools/private:/cygdrive/c/

Release news