Mailing List Archive

Calling User Program
Hi,

I am running sshd (version 5.2.p1) in my embedded platform and I can
succesfully login
from ssh client in remote host.

I like to do some modifications. i.e. After typing username and
password, I want to run a application program directly instead of
prompt. I like to know, which file has to be modified?

Thanks in Advance
Re: Calling User Program [ In reply to ]
On Tue, Aug 25, 2009 at 6:41 PM, linux newbie<linux.newbie79@gmail.com> wrote:
> Hi,
>
> I am running sshd (version 5.2.p1) in my embedded platform and I can
> succesfully login
> from ssh client in remote host.
>
> I like to do some modifications. i.e. After typing username and
> password, I want to run a application program directly instead of
> prompt. I like to know, which file has to be modified?
>
> Thanks in Advance
>

For wide-system setting:

/etc/profile (sh & bash)

Per-user settings:

~/.profile (sh & bash)
~/.bash_profile (bash)

Regards


Alberto Mijares
Re: Calling User Program [ In reply to ]
Thanks for suggestion.

On logging from remote-host to my server, It takes me to HOME
directory of root instead of /$USER directory. Hence even after
editing .profile in the user-directory, its not working.

Can you please suggest how to configure sshd to user-directory?

On Wed, Aug 26, 2009 at 9:54 AM, Alberto Mijares<amijaresp@gmail.com> wrote:
> On Tue, Aug 25, 2009 at 6:41 PM, linux newbie<linux.newbie79@gmail.com> wrote:
>> Hi,
>>
>> I am running sshd (version 5.2.p1) in my embedded platform and I can
>> succesfully login
>> from ssh client in remote host.
>>
>> I like to do some modifications. i.e. After typing username and
>> password, I want to run a application program directly instead of
>> prompt. I like to know, which file has to be modified?
>>
>> Thanks in Advance
>>
>
> For wide-system setting:
>
> /etc/profile (sh & bash)
>
> Per-user settings:
>
> ~/.profile (sh & bash)
> ~/.bash_profile (bash)
>
> Regards
>
>
> Alberto Mijares
>
Re: Calling User Program [ In reply to ]
Thanks got it working.

my /etc/profile "cd" to /home instead of /home/$USER

after editing this file things are working fine as expected.

Thanks for your support.

On Wed, Aug 26, 2009 at 10:12 AM, linux newbie<linux.newbie79@gmail.com> wrote:
> Thanks for suggestion.
>
> On logging from remote-host to my server, It takes me to HOME
> directory of root instead of /$USER directory. Hence even after
> editing .profile in the user-directory, its not working.
>
> Can you please suggest how to configure sshd to user-directory?
>
> On Wed, Aug 26, 2009 at 9:54 AM, Alberto Mijares<amijaresp@gmail.com> wrote:
>> On Tue, Aug 25, 2009 at 6:41 PM, linux newbie<linux.newbie79@gmail.com> wrote:
>>> Hi,
>>>
>>> I am running sshd (version 5.2.p1) in my embedded platform and I can
>>> succesfully login
>>> from ssh client in remote host.
>>>
>>> I like to do some modifications. i.e. After typing username and
>>> password, I want to run a application program directly instead of
>>> prompt. I like to know, which file has to be modified?
>>>
>>> Thanks in Advance
>>>
>>
>> For wide-system setting:
>>
>> /etc/profile (sh & bash)
>>
>> Per-user settings:
>>
>> ~/.profile (sh & bash)
>> ~/.bash_profile (bash)
>>
>> Regards
>>
>>
>> Alberto Mijares
>>
>
Re: Calling User Program [ In reply to ]
Hi Linux Newbie,

Theres a few ways of doing this.

- You can run a command by adding it to the command line when calling ssh.
ie. ssh <host> "command"
- If you're using keys instead of password authentication you can force
the server to invoke a command by adding "command=<command>" before the
user's key in the .ssh/authorized_keys file
- In sshd_config you can add the line "ForceCommand <command>". You can
wrap this in a "Match" conditional block
- Alter the server-side user's profile or the system-wide profile to
invoke a command upon logging in.

Regards,
David

listbounce@securityfocus.com wrote on 26/08/2009 07:11:11 AM:

> linux newbie <linux.newbie79@gmail.com>
> Sent by: listbounce@securityfocus.com
>
> 26/08/2009 07:11 AM
>
> To
>
> secureshell@securityfocus.com
>
> cc
>
> Subject
>
> Calling User Program
>
> Hi,
>
> I am running sshd (version 5.2.p1) in my embedded platform and I can
> succesfully login
> from ssh client in remote host.
>
> I like to do some modifications. i.e. After typing username and
> password, I want to run a application program directly instead of
> prompt. I like to know, which file has to be modified?
>
> Thanks in Advance
Re: Calling User Program [ In reply to ]
On Tue, Aug 25, 2009 at 4:11 PM, linux newbie<linux.newbie79@gmail.com> wrote:
> I like to do some modifications. i.e. After typing username and
> password, I want to run a application program directly instead of
> prompt. I like to know, which file has to be modified?

Have you tried changing the login shell for the user?

--
And, did Galoka think the Ulus were too ugly to save?
-Centauri
Re: Calling User Program [ In reply to ]
Though not strictly an SSH issue, I believe you can also override the
'shell' setting for a designated user. E.G. replace /bin/bash or
whatever SHELL you have assigned to that user with /path/to/my/app. The
result will be that login shall invoke /path/to/my/app.
read 'man 5 passwd' & 'man useradd'
Amit

Alberto Mijares wrote:
> On Tue, Aug 25, 2009 at 6:41 PM, linux newbie<linux.newbie79@gmail.com> wrote:
>
>> Hi,
>>
>> I am running sshd (version 5.2.p1) in my embedded platform and I can
>> succesfully login
>> from ssh client in remote host.
>>
>> I like to do some modifications. i.e. After typing username and
>> password, I want to run a application program directly instead of
>> prompt. I like to know, which file has to be modified?
>>
>> Thanks in Advance
>>
>>
>
> For wide-system setting:
>
> /etc/profile (sh & bash)
>
> Per-user settings:
>
> ~/.profile (sh & bash)
> ~/.bash_profile (bash)
>
> Regards
>
>
> Alberto Mijares
>
Re: Calling User Program [ In reply to ]
Alberto Mijares wrote:
> On Tue, Aug 25, 2009 at 6:41 PM, linux newbie<linux.newbie79@gmail.com> wrote:
>
>> Hi,
>>
>> I am running sshd (version 5.2.p1) in my embedded platform and I can
>> succesfully login
>> from ssh client in remote host.
>>
>> I like to do some modifications. i.e. After typing username and
>> password, I want to run a application program directly instead of
>> prompt. I like to know, which file has to be modified?
>>
>> Thanks in Advance
>>
> For wide-system setting:
>
> /etc/profile (sh & bash)
>
> Per-user settings:
>
> ~/.profile (sh & bash)
> ~/.bash_profile (bash)
>
> Regards
>
>
> Alberto Mijares
>
You should be able to set universal or per-user commands
in the sshd config file if I remember correctly, possibly a
simpler and more appropriate way to handle this, depending
on the type of command. (You might have to inform your
ssh client whether to grab a pty or not.)
Re: Calling User Program [ In reply to ]
On Tue, Aug 25, 2009 at 07:24:14PM -0430, Alberto Mijares wrote:
> On Tue, Aug 25, 2009 at 6:41 PM, linux newbie<linux.newbie79@gmail.com> wrote:
> > I am running sshd (version 5.2.p1) in my embedded platform [...]
> > I like to do some modifications. i.e. After typing username and
> > password, I want to run a application program directly instead of
> > prompt.

> For wide-system setting:
>
> /etc/profile (sh & bash)
>
> Per-user settings:
>
> ~/.profile (sh & bash)
> ~/.bash_profile (bash)

Another way would be to change the user's shell, from something like
/bin/bash or /bin/sh, to the program you want to execute (e.g.
/usr/local/bin/myscript). Make sure your embedded OS permits this
to be used as a shell, for example by putting it in /etc/shells, if
your embedded OS requires that.
Re: Calling User Program [ In reply to ]
On Tue, Aug 25, 2009 at 5:12 PM, linux newbie<linux.newbie79@gmail.com> wrote:
> On logging from remote-host to my server, It takes me to HOME
> directory of root instead of /$USER directory. Hence even after
> editing .profile in the user-directory, its not working.
>
> Can you please suggest how to configure sshd to user-directory?

All of this is controlled via the password file. (/etc/passwd)
Change the home directory to the correct (and existing) directory and
change the shell to be your application. When the user logs into the
system, sshd will chdir to the home directory and exec the login shell.
If you configure the login shell to be your application, then it will exec
your application.


--
And, did Galoka think the Ulus were too ugly to save?
-Centauri
Re: Calling User Program [ In reply to ]
On Wed, 2009-08-26 at 13:39 +0200, Bill Eldridge wrote:
> Alberto Mijares wrote:
> > On Tue, Aug 25, 2009 at 6:41 PM, linux newbie<linux.newbie79@gmail.com> wrote:
> >
> >> Hi,
> >>
> >> I am running sshd (version 5.2.p1) in my embedded platform and I can
> >> succesfully login
> >> from ssh client in remote host.
> >>
> >> I like to do some modifications. i.e. After typing username and
> >> password, I want to run a application program directly instead of
> >> prompt. I like to know, which file has to be modified?
> >>
> >> Thanks in Advance
> >>
> > For wide-system setting:
> >
> > /etc/profile (sh & bash)
> >
> > Per-user settings:
> >
> > ~/.profile (sh & bash)
> > ~/.bash_profile (bash)
> >
> > Regards
> >
> >
> > Alberto Mijares
> >
> You should be able to set universal or per-user commands
> in the sshd config file if I remember correctly, possibly a
> simpler and more appropriate way to handle this, depending
> on the type of command. (You might have to inform your
> ssh client whether to grab a pty or not.)

Just modify the users shell in /etc/passwd to the program you want to
run. You might have to also add the entry for your program
to /etc/shells or similar file showing your program as a valid "shell".

When the program exits, the user is disconnected.

Also, beware that your distro might have a tool used to edit the passwd,
if it does, you should use that.

HTH
~k
Re: Calling User Program [ In reply to ]
Sorry for late reply.

Yea, In my /etc/passwd file it points to user folder i.e /home/user,
but it seems chdir is not happening.

On Wed, Aug 26, 2009 at 11:05 AM, Robert Hajime
Lanning<robert.lanning@gmail.com> wrote:
> On Tue, Aug 25, 2009 at 4:11 PM, linux newbie<linux.newbie79@gmail.com> wrote:
>> I like to do some modifications. i.e. After typing username and
>> password, I want to run a application program directly instead of
>> prompt. I like to know, which file has to be modified?
>
> Have you tried changing the login shell for the user?
>
> --
> And, did Galoka think the Ulus were too ugly to save?
>                                         -Centauri
>
Re: Calling User Program [ In reply to ]
On Wed, Aug 26, 2009 at 8:33 PM, linux newbie<linux.newbie79@gmail.com> wrote:
> Yea, In my /etc/passwd file it points to user folder i.e /home/user,
> but it seems chdir is not happening.

In that case, you might want to look at permissions for the user to
access their home directory.

sshd should chdir and setup the environment, before exec()ing the login shell.

--
And, did Galoka think the Ulus were too ugly to save?
-Centauri