* sshd, plink, bash and path problems @ 2004-05-06 1:57 Tim Shadel 2004-05-06 2:26 ` Larry Hall 0 siblings, 1 reply; 6+ messages in thread From: Tim Shadel @ 2004-05-06 1:57 UTC (permalink / raw) To: cygwin I'm not subscribed to the list. Kindly CC: me in any threads that result from this email. Thanks. Here's my setup: Client: Win2K box with Putty/Plink Server: Win2K professional with cygwin/sshd (actually copssh, but it's just a minimal cygwin install) I can login just fine. I can use public key authentication fine. Here's what I'd like to do: plink -batch -2 -i C:\path\to\my\key\mykey.PPK -l tims 159.87.127.66 mkdir -p /var/some/dir/that/does/not/exist Nothing happens. Here's something else I tried to see what's going on: plink -batch -2 -i C:\path\to\my\key\mykey.PPK -l tims 159.87.127.66 echo $PATH /cygdrive/c/j2sdk... Basically my entire Windows path prints out -- NOT my cygwin path. I saw another post on this in a different context (http://www.cygwin.com/ml/cygwin/2003-07/msg01700.html), and I can see that it's a matter of commands getting executed when the login process happens. So then I tried this: plink -batch -2 -i C:\path\to\my\key\mykey.PPK -l tims 159.87.127.66 source /etc/profile; echo $PATH /bin:/cygdrive/c/WINNT/system32:/cygdrive/c/WINNT And got the output I expected. BUT, the plink command is being issued by a program that I can't modify (apache's maven deploy plugin), so I wondered two things: 1. What's different between plink <host> <command> and plink <host> (which displays a prompt) that causes the magical "login" process to occur. Is this a plink thing? a bash thing? a cygwin-version-of-either thing? 2. Is there a file (.rc something-or-other perhaps?) that I can create that will make the "source /etc/profile" call once plink connects, so I can have the right path when <command> happens? Any help with this would be most appreciated. Thanks, Tim Shadel -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: sshd, plink, bash and path problems 2004-05-06 1:57 sshd, plink, bash and path problems Tim Shadel @ 2004-05-06 2:26 ` Larry Hall 2004-05-06 18:01 ` Tim Shadel 0 siblings, 1 reply; 6+ messages in thread From: Larry Hall @ 2004-05-06 2:26 UTC (permalink / raw) To: Tim Shadel, cygwin At 09:56 PM 5/5/2004, you wrote: >I'm not subscribed to the list. Kindly CC: me in any threads that result from this email. Thanks. > >Here's my setup: > >Client: Win2K box with Putty/Plink >Server: Win2K professional with cygwin/sshd (actually copssh, but it's just a minimal cygwin install) > >I can login just fine. I can use public key authentication fine. > >Here's what I'd like to do: > >plink -batch -2 -i C:\path\to\my\key\mykey.PPK -l tims 159.87.127.66 mkdir -p /var/some/dir/that/does/not/exist > >Nothing happens. Here's something else I tried to see what's going on: > >plink -batch -2 -i C:\path\to\my\key\mykey.PPK -l tims 159.87.127.66 echo $PATH >/cygdrive/c/j2sdk... > >Basically my entire Windows path prints out -- NOT my cygwin path. I saw another post on this in a different context (http://www.cygwin.com/ml/cygwin/2003-07/msg01700.html), and I can see that it's a matter of commands getting executed when the login process happens. So then I tried this: > >plink -batch -2 -i C:\path\to\my\key\mykey.PPK -l tims 159.87.127.66 source /etc/profile; echo $PATH >/bin:/cygdrive/c/WINNT/system32:/cygdrive/c/WINNT > >And got the output I expected. BUT, the plink command is being issued by a program that I can't modify (apache's maven deploy plugin), so I wondered two things: > >1. What's different between plink <host> <command> and plink <host> (which displays a prompt) that causes the magical "login" process to occur. Is this a plink thing? a bash thing? a cygwin-version-of-either thing? > >2. Is there a file (.rc something-or-other perhaps?) that I can create that will make the "source /etc/profile" call once plink connects, so I can have the right path when <command> happens? > >Any help with this would be most appreciated. Sorry, I don't use putty or plink (and actually since they aren't part of the Cygwin distribution, much discussion of them is off-topic for this list). But I expect your problem isn't putty/plink specific but rather operator-error. I can reproduce the same "problem" you're reporting with 'ssh' (which is part of the Cygwin distribution). I believe you want: plink -batch -2 -i C:\path\to\my\key\mykey.PPK -l tims 159.87.127.66 'echo $PATH' Does that clarify what's going on for you? -- Larry Hall http://www.rfk.com RFK Partners, Inc. (508) 893-9779 - RFK Office 838 Washington Street (508) 893-9889 - FAX Holliston, MA 01746 -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: sshd, plink, bash and path problems 2004-05-06 2:26 ` Larry Hall @ 2004-05-06 18:01 ` Tim Shadel 2004-05-06 19:03 ` Igor Pechtchanski 0 siblings, 1 reply; 6+ messages in thread From: Tim Shadel @ 2004-05-06 18:01 UTC (permalink / raw) To: Cygwin List; +Cc: Larry Hall I'm not subscribed to the list. Kindly CC: me in any threads that result from this email. Thanks. Larry Hall wrote: > Sorry, I don't use putty or plink (and actually since they aren't part > ofthe Cygwin distribution, much discussion of them is off-topic for > this list). Understood. I'll try rephrase my original question in terms of ssh. > But I expect your problem isn't putty/plink specific but rather > operator-error. I can reproduce the same "problem" you're reporting > with 'ssh' (which is part of the Cygwin distribution). I believe you want: > >plink -batch -2 -i C:\path\to\my\key\mykey.PPK -l tims 159.87.127.66 'echo $PATH' > > Hmm. I tried to replicate this with 'ssh' as well, after you mentioned it. Here's what I did: 1. Use Putty to connect to the cygwin machine via SSH. 2. Use 'ssh-keygen' to create a key on the cygwin machine, and add it to the authorized_keys file. 3. Use 'ssh-agent' and 'ssh-add' to hold my key in memory so it can be used without a prompt 4. Use 'ssh localhost <command>' to simulate the 'plink' setup I described earlier What I found is this: (a) ssh localhost echo $PATH returned the correct cygwin path, but (b) ssh localhost 'echo $PATH' returned the full Windows path, not the cygwin path, and (c) ssh localhost "echo $PATH" returned the correct cygwin path as well. But as I think about it, I actually can't change the quotes used around the command (since it's issued by a program over which I have no control). What I CAN manipulate is the cygwin environment contacted by the ssh/plink program. >1. What's different between plink <host> <command> and plink <host> (which displays a prompt) that causes the magical "login" process to occur. Is this a plink thing? a bash thing? a cygwin-version-of-either thing? > > Let me rephrase this a bit. What happens differently between (a) and (b) above on the _server_ side? >2. Is there a file (.rc something-or-other perhaps?) that I can create that will make the "source /etc/profile" call once plink connects, so I can have the right path when <command> happens? > > Can I change the cygwin environment (server side) to handle both (a) and (b) in the same way? I'm familiar with Linux, but Cygwin (and especially its interaction with Windows: environment, permissions, etc) is brand new to me. The quotation difference is step in the right direction (I know what to rule out), and I'm sure with a bit more info I'll be able solve my problem. I appreciate your help. Thanks, Tim -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: sshd, plink, bash and path problems 2004-05-06 18:01 ` Tim Shadel @ 2004-05-06 19:03 ` Igor Pechtchanski 2004-05-06 21:41 ` Tim Shadel 0 siblings, 1 reply; 6+ messages in thread From: Igor Pechtchanski @ 2004-05-06 19:03 UTC (permalink / raw) To: Tim Shadel; +Cc: cygwin On Thu, 6 May 2004, Tim Shadel wrote: > I'm not subscribed to the list. Kindly CC: me in any threads that > result from this email. Thanks. > > [snip] > What I found is this: > > (a) ssh localhost echo $PATH > > returned the correct cygwin path, but > > (b) ssh localhost 'echo $PATH' > > returned the full Windows path, not the cygwin path, and > > (c) ssh localhost "echo $PATH" > > returned the correct cygwin path as well. But as I think about it, I > actually can't change the quotes used around the command (since it's > issued by a program over which I have no control). What I CAN > manipulate is the cygwin environment contacted by the ssh/plink program. > > >1. What's different between plink <host> <command> and plink <host> > >(which displays a prompt) that causes the magical "login" process to > >occur. Is this a plink thing? a bash thing? a cygwin-version-of-either > >thing? It's a plink thing. FWIW, ssh behaves similarly. > Let me rephrase this a bit. What happens differently between (a) and > (b) above on the _server_ side? Why not try it locally, like this: echo echo $PATH echo 'echo $PATH' echo "echo $PATH" and then sh -xc 'PATH=/blah;echo $PATH' sh -xc "PATH=/blah;echo $PATH" > >2. Is there a file (.rc something-or-other perhaps?) that I can create > >that will make the "source /etc/profile" call once plink connects, so I > >can have the right path when <command> happens? Well, you can tell ssh to invoke a login shell (e.g., "ssh a@b bash -l -c 'commands'"). I don't know about plink. > Can I change the cygwin environment (server side) to handle both (a) and > (b) in the same way? No. If you run the above experiments, you'll see why. > I'm familiar with Linux, but Cygwin (and especially its interaction with > Windows: environment, permissions, etc) is brand new to me. This has nothing to do with Cygwin. This is pure shell stuff. > The quotation difference is step in the right direction (I know what to > rule out), and I'm sure with a bit more info I'll be able solve my > problem. I appreciate your help. > > Thanks, > Tim HTH, Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha@cs.nyu.edu ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "I have since come to realize that being between your mentor and his route to the bathroom is a major career booster." -- Patrick Naughton -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: sshd, plink, bash and path problems 2004-05-06 19:03 ` Igor Pechtchanski @ 2004-05-06 21:41 ` Tim Shadel 2004-05-06 21:47 ` Igor Pechtchanski 0 siblings, 1 reply; 6+ messages in thread From: Tim Shadel @ 2004-05-06 21:41 UTC (permalink / raw) To: cygwin; +Cc: Igor Pechtchanski Igor Pechtchanski wrote: >Why not try it locally, like this: > >echo echo $PATH >echo 'echo $PATH' >echo "echo $PATH" > >and then > >sh -xc 'PATH=/blah;echo $PATH' >sh -xc "PATH=/blah;echo $PATH" > Aah. I forgot about the meanings of various quotes in bash. That's an excellent example. >>>2. Is there a file (.rc something-or-other perhaps?) that I can create >>>that will make the "source /etc/profile" call once plink connects, so I >>>can have the right path when <command> happens? >>> >>> > >Well, you can tell ssh to invoke a login shell (e.g., "ssh a@b bash -l -c >'commands'"). I don't know about plink. > plink also allows commands to be run. That "bash -l -c 'commands'" works great. I see if there's any way to change the code to use it, but that solves my problem. >>Can I change the cygwin environment (server side) to handle both (a) and >>(b) in the same way? >> >> > >No. If you run the above experiments, you'll see why. > Yup. Thanks. >This has nothing to do with Cygwin. This is pure shell stuff. > > I guess I didn't know the original PATH was the windows one. That makes more sense now. So I'd see the same thing on a Linux box using pure ssh. If the PATH were changed by /etc/profile, and I didn't use the "bash -l -c 'commands'" stuff to force a bash login, then I wouldn't see the new PATH there either. I assume that the only way to 'source /etc/profile' requires a change to the content after "ssh a@b". For example, '"ssh a@b bash -l -c 'commands'" and "ssh a@b source /etc/profile; commands" both work for me. I only wish I could "ssh a@b commands" and have it work. I've got the info I need to figure out a different solution, though. Thanks! >HTH, > Igor > > It helps immensely. Thank you very much. Tim -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: sshd, plink, bash and path problems 2004-05-06 21:41 ` Tim Shadel @ 2004-05-06 21:47 ` Igor Pechtchanski 0 siblings, 0 replies; 6+ messages in thread From: Igor Pechtchanski @ 2004-05-06 21:47 UTC (permalink / raw) To: Tim Shadel; +Cc: cygwin On Thu, 6 May 2004, Tim Shadel wrote: > Igor Pechtchanski wrote: > > [snip] > >>>2. Is there a file (.rc something-or-other perhaps?) that I can create > >>>that will make the "source /etc/profile" call once plink connects, so I > >>>can have the right path when <command> happens? > > > >Well, you can tell ssh to invoke a login shell (e.g., "ssh a@b bash -l -c > >'commands'"). I don't know about plink. > > plink also allows commands to be run. That "bash -l -c 'commands'" > works great. I see if there's any way to change the code to use it, but > that solves my problem. > > [snip] > >This has nothing to do with Cygwin. This is pure shell stuff. > > I guess I didn't know the original PATH was the windows one. That makes > more sense now. So I'd see the same thing on a Linux box using pure > ssh. If the PATH were changed by /etc/profile, and I didn't use the > "bash -l -c 'commands'" stuff to force a bash login, then I wouldn't see > the new PATH there either. > > I assume that the only way to 'source /etc/profile' requires a change to > the content after "ssh a@b". For example, '"ssh a@b bash -l -c > 'commands'" and "ssh a@b source /etc/profile; commands" both work for > me. I only wish I could "ssh a@b commands" and have it work. I've got > the info I need to figure out a different solution, though. Thanks! If you set up your variables in ~/.bashrc instead of /etc/profile, that should get executed on every bash invocation (assuming your remote shell is "bash"). Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha@cs.nyu.edu ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "I have since come to realize that being between your mentor and his route to the bathroom is a major career booster." -- Patrick Naughton -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-05-06 21:41 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-05-06 1:57 sshd, plink, bash and path problems Tim Shadel 2004-05-06 2:26 ` Larry Hall 2004-05-06 18:01 ` Tim Shadel 2004-05-06 19:03 ` Igor Pechtchanski 2004-05-06 21:41 ` Tim Shadel 2004-05-06 21:47 ` Igor Pechtchanski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).