Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: OpenSSH: Users

Calling User Program

 

 

OpenSSH users RSS feed   Index | Next | Previous | View Threaded


linux.newbie79 at gmail

Aug 25, 2009, 4:11 PM

Post #1 of 13 (2702 views)
Permalink
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


amijaresp at gmail

Aug 25, 2009, 4:54 PM

Post #2 of 13 (2606 views)
Permalink
Re: Calling User Program [In reply to]

On Tue, Aug 25, 2009 at 6:41 PM, linux newbie<linux.newbie79 [at] gmail> 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


linux.newbie79 at gmail

Aug 25, 2009, 5:12 PM

Post #3 of 13 (2598 views)
Permalink
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 [at] gmail> wrote:
> On Tue, Aug 25, 2009 at 6:41 PM, linux newbie<linux.newbie79 [at] gmail> 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
>


linux.newbie79 at gmail

Aug 25, 2009, 5:43 PM

Post #4 of 13 (2594 views)
Permalink
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 [at] gmail> 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 [at] gmail> wrote:
>> On Tue, Aug 25, 2009 at 6:41 PM, linux newbie<linux.newbie79 [at] gmail> 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
>>
>


dgreen49 at csc

Aug 25, 2009, 5:57 PM

Post #5 of 13 (2601 views)
Permalink
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 [at] securityfocus wrote on 26/08/2009 07:11:11 AM:

> linux newbie <linux.newbie79 [at] gmail>
> Sent by: listbounce [at] securityfocus
>
> 26/08/2009 07:11 AM
>
> To
>
> secureshell [at] securityfocus
>
> 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


robert.lanning at gmail

Aug 25, 2009, 6:05 PM

Post #6 of 13 (2607 views)
Permalink
Re: Calling User Program [In reply to]

On Tue, Aug 25, 2009 at 4:11 PM, linux newbie<linux.newbie79 [at] gmail> 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


amitds at oversi

Aug 26, 2009, 12:01 AM

Post #7 of 13 (2584 views)
Permalink
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 [at] gmail> 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
>


dcbill at volny

Aug 26, 2009, 4:39 AM

Post #8 of 13 (2596 views)
Permalink
Re: Calling User Program [In reply to]

Alberto Mijares wrote:
> On Tue, Aug 25, 2009 at 6:41 PM, linux newbie<linux.newbie79 [at] gmail> 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.)


wooledg at eeg

Aug 26, 2009, 5:23 AM

Post #9 of 13 (2595 views)
Permalink
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 [at] gmail> 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.


robert.lanning at gmail

Aug 26, 2009, 11:49 AM

Post #10 of 13 (2593 views)
Permalink
Re: Calling User Program [In reply to]

On Tue, Aug 25, 2009 at 5:12 PM, linux newbie<linux.newbie79 [at] gmail> 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


kurth at kurthbemis

Aug 26, 2009, 3:01 PM

Post #11 of 13 (2585 views)
Permalink
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 [at] gmail> 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


linux.newbie79 at gmail

Aug 26, 2009, 8:33 PM

Post #12 of 13 (2590 views)
Permalink
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 [at] gmail> wrote:
> On Tue, Aug 25, 2009 at 4:11 PM, linux newbie<linux.newbie79 [at] gmail> 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
>


robert.lanning at gmail

Aug 27, 2009, 1:49 AM

Post #13 of 13 (2586 views)
Permalink
Re: Calling User Program [In reply to]

On Wed, Aug 26, 2009 at 8:33 PM, linux newbie<linux.newbie79 [at] gmail> 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

OpenSSH users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.