You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Dougal Graham <do...@gmail.com> on 2020/06/17 04:03:46 UTC

sshexec sshConfig does not seem to work as expected (by me)

Hi Everyone,

I just upgraded Ant to 1.10.8 so that I can use the new sshConfig feature
of sshexec, so I don't need to hardcode the location of the user's keyfile
in my script. I am now using it like so:

<sshexec
    trust="true"
    host="${app.hostname}"
    username="${app.username}"
    verbose="true"
    sshConfig="${user.home}/.ssh/config"
    command="do some things"
/>


However, I still receive warnings about a missing keyfile or password.
Isn't the point of the sshConfig parameter to let me leave off those
parameters?

Any help is appreciated. I've also run the ant debugger to ensure that it's
the right version, and so forth, and everything seems to be correct, and it
is in fact v1.10.8.

Any suggestions are welcome. Thank you,

Dougal Graham

Re: sshexec sshConfig does not seem to work as expected (by me)

Posted by Dougal Graham <do...@gmail.com>.
Yes, will do.

Thanks again for your help!

On Wed, Jun 17, 2020 at 12:23 PM Jaikiran Pai <ja...@gmail.com>
wrote:

> Yes that looks like a bug. Can you create a bugzilla issue for this please?
>
> -Jaikiran
> On 17/06/20 10:52 am, Dougal Graham wrote:
>
> OK, after digging a little bit, it turns out that I didn't have a default
> identity file set in my ssh config.
>
> After rectifying that issue, I thought things were fixed, but actually,
> they are still broken!
>
>   [sshexec] Loading SSH configuration file /Users/dougal/.ssh/config
>   [sshexec] Using SSH key file ~/.ssh/id_rsa for host null
>   [sshexec] Caught exception: host must not be null.
>
> So I looked at the code again, and it seems that after loading the SSH
> config file, it overrides the current host with the host from the SSH
> config. So, if you just specify a default identity file in your config,
> then the host gets blown away:
>
> host = config.getHostname();
>
>
> Assuming I am interpreting this correctly...
>
> On Wed, Jun 17, 2020 at 11:59 AM Dougal Graham <do...@gmail.com> wrote:
>
>> You are, of course, correct! Thank you.
>>
>> OK, running with debug I see:
>>
>>   [sshexec] Loading SSH configuration file /Users/dougal/.ssh/config
>>   [sshexec] Using SSH key file null for host null
>>
>> So maybe it isn't picking up my host/default ssh key properly. ie: maybe
>> I've configured my host wrong, or my ssh config incorrectly.
>>
>> Thanks again for your help!
>>
>> On Wed, Jun 17, 2020 at 11:40 AM Jaikiran Pai <ja...@gmail.com>
>> wrote:
>>
>>> Hello Dougal,
>>> On 17/06/20 10:07 am, Dougal Graham wrote:
>>>
>>> Hi Jaikaran,
>>>
>>> Thanks for getting back to me. I just got the code downloaded for Ant,
>>> and I think I see the problem:
>>>
>>> protected void loadSshConfig() throws BuildException {
>>>     if (sshConfig != null && (userInfo.getName() == null || userInfo.getKeyfile() == null)) {
>>>
>>> It would seem that the sshConfig file is only used if both name and
>>> keyfile are empty.
>>>
>>> Looking at that code, the sshConfig file will be used if the username
>>> *or* (not and) keyfile is not specified. i.e. if either of them is not
>>> specified. So from what I saw in the original task definition that you
>>> pasted, I think the sshConfig file should have been used.
>>>
>>> -Jaikiran
>>>
>>
>>
>> --
>> Dougal Graham
>>
>
>
> --
> Dougal Graham
>
>

-- 
Dougal Graham

Re: sshexec sshConfig does not seem to work as expected (by me)

Posted by Jaikiran Pai <ja...@gmail.com>.
Yes that looks like a bug. Can you create a bugzilla issue for this please?

-Jaikiran

On 17/06/20 10:52 am, Dougal Graham wrote:
> OK, after digging a little bit, it turns out that I didn't have a
> default identity file set in my ssh config.
>
> After rectifying that issue, I thought things were fixed, but
> actually, they are still broken!
>
>   [sshexec] Loading SSH configuration file /Users/dougal/.ssh/config
>   [sshexec] Using SSH key file ~/.ssh/id_rsa for host null
>   [sshexec] Caught exception: host must not be null.
>
> So I looked at the code again, and it seems that after loading the SSH
> config file, it overrides the current host with the host from the SSH
> config. So, if you just specify a default identity file in your
> config, then the host gets blown away:
> host = config.getHostname();
>
> Assuming I am interpreting this correctly...
>
> On Wed, Jun 17, 2020 at 11:59 AM Dougal Graham <dougalg@gmail.com
> <ma...@gmail.com>> wrote:
>
>     You are, of course, correct! Thank you.
>
>     OK, running with debug I see:
>
>       [sshexec] Loading SSH configuration file /Users/dougal/.ssh/config
>       [sshexec] Using SSH key file null for host null
>
>     So maybe it isn't picking up my host/default ssh key properly. ie:
>     maybe I've configured my host wrong, or my ssh config incorrectly.
>
>     Thanks again for your help!
>
>     On Wed, Jun 17, 2020 at 11:40 AM Jaikiran Pai
>     <jai.forums2013@gmail.com <ma...@gmail.com>> wrote:
>
>         Hello Dougal,
>
>         On 17/06/20 10:07 am, Dougal Graham wrote:
>>         Hi Jaikaran,
>>
>>         Thanks for getting back to me. I just got the code downloaded
>>         for Ant, and I think I see the problem:
>>
>>         protected void loadSshConfig() throws BuildException {
>>             if (sshConfig != null && (userInfo.getName() == null || userInfo.getKeyfile() == null)) {
>>         It would seem that the sshConfig file is only used if both
>>         name and keyfile are empty.
>
>         Looking at that code, the sshConfig file will be used if the
>         username *or* (not and) keyfile is not specified. i.e. if
>         either of them is not specified. So from what I saw in the
>         original task definition that you pasted, I think the
>         sshConfig file should have been used.
>
>         -Jaikiran
>
>
>
>     -- 
>     Dougal Graham
>
>
>
> -- 
> Dougal Graham

Re: sshexec sshConfig does not seem to work as expected (by me)

Posted by Dougal Graham <do...@gmail.com>.
OK, after digging a little bit, it turns out that I didn't have a default
identity file set in my ssh config.

After rectifying that issue, I thought things were fixed, but actually,
they are still broken!

  [sshexec] Loading SSH configuration file /Users/dougal/.ssh/config
  [sshexec] Using SSH key file ~/.ssh/id_rsa for host null
  [sshexec] Caught exception: host must not be null.

So I looked at the code again, and it seems that after loading the SSH
config file, it overrides the current host with the host from the SSH
config. So, if you just specify a default identity file in your config,
then the host gets blown away:

host = config.getHostname();


Assuming I am interpreting this correctly...

On Wed, Jun 17, 2020 at 11:59 AM Dougal Graham <do...@gmail.com> wrote:

> You are, of course, correct! Thank you.
>
> OK, running with debug I see:
>
>   [sshexec] Loading SSH configuration file /Users/dougal/.ssh/config
>   [sshexec] Using SSH key file null for host null
>
> So maybe it isn't picking up my host/default ssh key properly. ie: maybe
> I've configured my host wrong, or my ssh config incorrectly.
>
> Thanks again for your help!
>
> On Wed, Jun 17, 2020 at 11:40 AM Jaikiran Pai <ja...@gmail.com>
> wrote:
>
>> Hello Dougal,
>> On 17/06/20 10:07 am, Dougal Graham wrote:
>>
>> Hi Jaikaran,
>>
>> Thanks for getting back to me. I just got the code downloaded for Ant,
>> and I think I see the problem:
>>
>> protected void loadSshConfig() throws BuildException {
>>     if (sshConfig != null && (userInfo.getName() == null || userInfo.getKeyfile() == null)) {
>>
>> It would seem that the sshConfig file is only used if both name and
>> keyfile are empty.
>>
>> Looking at that code, the sshConfig file will be used if the username
>> *or* (not and) keyfile is not specified. i.e. if either of them is not
>> specified. So from what I saw in the original task definition that you
>> pasted, I think the sshConfig file should have been used.
>>
>> -Jaikiran
>>
>
>
> --
> Dougal Graham
>


-- 
Dougal Graham

Re: sshexec sshConfig does not seem to work as expected (by me)

Posted by Dougal Graham <do...@gmail.com>.
You are, of course, correct! Thank you.

OK, running with debug I see:

  [sshexec] Loading SSH configuration file /Users/dougal/.ssh/config
  [sshexec] Using SSH key file null for host null

So maybe it isn't picking up my host/default ssh key properly. ie: maybe
I've configured my host wrong, or my ssh config incorrectly.

Thanks again for your help!

On Wed, Jun 17, 2020 at 11:40 AM Jaikiran Pai <ja...@gmail.com>
wrote:

> Hello Dougal,
> On 17/06/20 10:07 am, Dougal Graham wrote:
>
> Hi Jaikaran,
>
> Thanks for getting back to me. I just got the code downloaded for Ant, and
> I think I see the problem:
>
> protected void loadSshConfig() throws BuildException {
>     if (sshConfig != null && (userInfo.getName() == null || userInfo.getKeyfile() == null)) {
>
> It would seem that the sshConfig file is only used if both name and
> keyfile are empty.
>
> Looking at that code, the sshConfig file will be used if the username *or*
> (not and) keyfile is not specified. i.e. if either of them is not
> specified. So from what I saw in the original task definition that you
> pasted, I think the sshConfig file should have been used.
>
> -Jaikiran
>


-- 
Dougal Graham

Re: sshexec sshConfig does not seem to work as expected (by me)

Posted by Jaikiran Pai <ja...@gmail.com>.
Hello Dougal,

On 17/06/20 10:07 am, Dougal Graham wrote:
> Hi Jaikaran,
>
> Thanks for getting back to me. I just got the code downloaded for Ant,
> and I think I see the problem:
>
> protected void loadSshConfig() throws BuildException {
>     if (sshConfig != null && (userInfo.getName() == null || userInfo.getKeyfile() == null)) {
> It would seem that the sshConfig file is only used if both name and
> keyfile are empty.

Looking at that code, the sshConfig file will be used if the username
*or* (not and) keyfile is not specified. i.e. if either of them is not
specified. So from what I saw in the original task definition that you
pasted, I think the sshConfig file should have been used.

-Jaikiran


Re: sshexec sshConfig does not seem to work as expected (by me)

Posted by Dougal Graham <do...@gmail.com>.
Hi Jaikaran,

Thanks for getting back to me. I just got the code downloaded for Ant, and
I think I see the problem:

protected void loadSshConfig() throws BuildException {
    if (sshConfig != null && (userInfo.getName() == null ||
userInfo.getKeyfile() == null)) {

It would seem that the sshConfig file is only used if both name and keyfile
are empty. IMO it would make more sense to use the sshConfig file as
fallback for values not specified explicitly in the config, probably.

If I have time I may see if I can submit an enhancement PR for this
behaviour, as it would be much more flexible.

Warm regards,

On Wed, Jun 17, 2020 at 11:29 AM Jaikiran Pai <ja...@gmail.com>
wrote:

> Hello Dougal,
>
> Can you get us the ant debug logs (using the -debug switch) when you run
> this target?
>
> -Jaikiran
>
> On 17/06/20 9:33 am, Dougal Graham wrote:
> > Hi Everyone,
> >
> > I just upgraded Ant to 1.10.8 so that I can use the new sshConfig feature
> > of sshexec, so I don't need to hardcode the location of the user's
> keyfile
> > in my script. I am now using it like so:
> >
> > <sshexec
> >     trust="true"
> >     host="${app.hostname}"
> >     username="${app.username}"
> >     verbose="true"
> >     sshConfig="${user.home}/.ssh/config"
> >     command="do some things"
> > />
> >
> >
> > However, I still receive warnings about a missing keyfile or password.
> > Isn't the point of the sshConfig parameter to let me leave off those
> > parameters?
> >
> > Any help is appreciated. I've also run the ant debugger to ensure that
> it's
> > the right version, and so forth, and everything seems to be correct, and
> it
> > is in fact v1.10.8.
> >
> > Any suggestions are welcome. Thank you,
> >
> > Dougal Graham
> >
>


-- 
Dougal Graham

Re: sshexec sshConfig does not seem to work as expected (by me)

Posted by Jaikiran Pai <ja...@gmail.com>.
Hello Dougal,

Can you get us the ant debug logs (using the -debug switch) when you run
this target?

-Jaikiran

On 17/06/20 9:33 am, Dougal Graham wrote:
> Hi Everyone,
>
> I just upgraded Ant to 1.10.8 so that I can use the new sshConfig feature
> of sshexec, so I don't need to hardcode the location of the user's keyfile
> in my script. I am now using it like so:
>
> <sshexec
>     trust="true"
>     host="${app.hostname}"
>     username="${app.username}"
>     verbose="true"
>     sshConfig="${user.home}/.ssh/config"
>     command="do some things"
> />
>
>
> However, I still receive warnings about a missing keyfile or password.
> Isn't the point of the sshConfig parameter to let me leave off those
> parameters?
>
> Any help is appreciated. I've also run the ant debugger to ensure that it's
> the right version, and so forth, and everything seems to be correct, and it
> is in fact v1.10.8.
>
> Any suggestions are welcome. Thank you,
>
> Dougal Graham
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org