[aklug] Re: PATH for non-interactive ssh stuff?

From: Christopher Howard <choward@indicium.us>
Date: Sun Aug 15 2010 - 09:46:27 AKDT

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/15/10 08:35, Matt Grimm wrote:
> You can source your bash_profile in the ssh command:
>
> $ ssh myusername@myremoteserver.com 'source ~/.bash_profile; echo $PATH'
>
>
> On Sat, Aug 14, 2010 at 11:25 PM, Christopher Howard
> <choward@indicium.us> wrote:
> On 08/14/10 23:16, Christopher Howard wrote:
>>>> On 08/14/10 22:05, Joshua J. Kugler wrote:
>>>>> On Saturday 14 August 2010, Christopher Howard elucidated thus:
>>>>>> Problem: I installed git in my HOME directory on a remote system I
>>>>>> don't have root access to. Works great when I'm logged-in, but when I
>>>>>> try to clone a repo over ssh, I get this: (command is being executed
>>>>>> on my local computer, to clone repo on remote system where I did the
>>>>>> git custom install)
>>>>>>
>>>>>> bash: git-upload-pack: command not found
>>>>>> fatal: The remote end hung up unexpectedly
>>>>>>
>>>>>> What is happening is, over SSH, it can't find that binary. Its
>>>>>> installed in ~/bin, but that isn't in the PATH:
>>>>>>
>>>>>> $ ssh myusername@myremoteserver.com echo \$PATH
>>>>>> /usr/bin:/bin
>>>>>>
>>>>>> Adding info to the PATH in .bashrc or .profile on the remote system
>>>>>> doesn't change the PATH displayed when I run the previous command.
>>>>
>>>>> I have this in my profile:
>>>>
>>>>> # set PATH so it includes user's private bin if it exists
>>>>> if [ -d "$HOME/bin" ] ; then
>>>>> =A0 =A0 PATH=3D"$HOME/bin:$PATH"
>>>>> fi
>>>>
>>>>> There is a note at the top of .profile, though:
>>>>
>>>>> # ~/.profile: executed by the command interpreter for login shells.
>>>>> # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
>>>>> # exists.
>>>>
>>>>> Hope that helps.
>>>>
>>>>> j
>>>>
>>>>
>>>> Thanks, but no, that doesn't help. My problem is that the .profile and
>>>> .bashrc files are apparently not being read before the non-interactive
>>>> session.
>>>>
>>>> I did additional research. The SSH(1) indicates:
>>>>
>>>> "Additionally, ssh reads ~/.ssh/environment, and adds lines of the
>>>> format ``VARNAME=3Dvalue'' to the environment if the file exists and use=
>> rs
>>>> are allowed to change their environment. =A0For more information, see th=
>> e
>>>> PermitUserEnvironment option in sshd_config(5)."
>>>>
>>>> Unfortunately, this does not seem to work for me. I'm guessing that said
>>>> PermitUserEnvironment is not set, although I can't find out for sure
>>>> because I can't even find an sshd_config file on the remote system.
>>>>
>>>> (grrrr...) I wish I was working with a self-managed server. Did you know
>>>> you can get a dedicated 1.7Ghz machine for $40 a month?
>>>> (https://www.sevenl.net/servers/147) Unfortunately, I'm probably not
>>>> going to be able to convince my client that a switch from $8 a month to
>>>> $40 a month is necessary because it will me configuration easier for the
>>>> web guy. >:(
>>>>
>
> Praise Providence... There is a work-around. The "git clone" function
> has an "--upload-pack" switch which allows you to set a path to the
> remote git program used for compression.
>
> =A0git --upload-pack /home/myuser/bin/git-upload-pack
> ssh://myuser@example.com/my_repo my_repo
>
> So, I solved my problem, if not the fundamental one.
>

Thanks everyone, but I already know that you can set the environment
variables yourself if you are running the ssh command yourself. In this
case, however, git is the program running the ssh command. I was trying
to figure out how to set the environment through some other means (like
the .ssh/environment file). Fortunately, this is no longer an issue (for
me) because I found out that git has the --upload-pack which allows you
to tell git where to find the git-upload-pack binary before it runs its
ssh commands.

- --
Christopher Howard
frigidcode.com
theologia.indicium.us
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxoJ/MACgkQQ5FLNdi0BcWaEQCgg2vV/GRdnrQdEAw0hjFjXn1x
7ksAn08W00N1V7OXXYEUOUF3Ug37+7C9
=dsdU
-----END PGP SIGNATURE-----
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Sun Aug 15 09:43:57 2010

This archive was generated by hypermail 2.1.8 : Sun Aug 15 2010 - 09:43:57 AKDT