Discussion:
Calling User Program
(too old to reply)
linux newbie
2009-08-25 23:22:20 UTC
Permalink
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
Alberto Mijares
2009-08-26 00:04:03 UTC
Permalink
Post by linux newbie
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 newbie
2009-08-26 18:37:00 UTC
Permalink
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.
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?
Post by Alberto Mijares
Post by linux newbie
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
/etc/profile (sh & bash)
~/.profile (sh & bash)
~/.bash_profile (bash)
Regards
Alberto Mijares
linux newbie
2009-08-26 18:38:54 UTC
Permalink
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?
Post by Alberto Mijares
Post by linux newbie
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
/etc/profile (sh & bash)
~/.profile (sh & bash)
~/.bash_profile (bash)
Regards
Alberto Mijares
Bill Eldridge
2009-08-26 21:52:07 UTC
Permalink
Post by Alberto Mijares
Post by linux newbie
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
/etc/profile (sh & bash)
~/.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.)
Robert Hajime Lanning
2009-08-26 21:54:37 UTC
Permalink
Post by linux newbie
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 Hajime Lanning
2009-08-26 21:57:07 UTC
Permalink
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
Greg Wooledge
2009-08-26 21:59:40 UTC
Permalink
Post by Alberto Mijares
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.
/etc/profile (sh & bash)
~/.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.
Amit Dor-Shifer
2009-08-26 22:05:57 UTC
Permalink
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
Post by Alberto Mijares
Post by linux newbie
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
/etc/profile (sh & bash)
~/.profile (sh & bash)
~/.bash_profile (bash)
Regards
Alberto Mijares
Daniel Llewellyn
2009-08-26 22:12:00 UTC
Permalink
and again I don't send to the list


---------- Forwarded message ----------
From: Daniel Llewellyn <***@xyz-network.com>
Date: Wed, Aug 26, 2009 at 14:57
Subject: Re: Calling User Program
Post by Alberto Mijares
Post by linux newbie
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
~/.profile (sh & bash)
~/.bash_profile (bash)
or for enforced peruser settings by the administrator that the user
can't change, modify the user's defined shell. This is often defined
in /etc/passwd, but may come from other places such as LDAP, NIS or
Active Directory for three examples.

--
Regards,
=C2=A0 =C2=A0Daniel Llewellyn



--=20
Regards,
Daniel Llewellyn
David R Green
2009-08-26 22:13:34 UTC
Permalink
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
26/08/2009 07:11 AM
To
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
H. Kurth Bemis
2009-08-27 16:22:34 UTC
Permalink
Post by Bill Eldridge
Post by Alberto Mijares
Post by linux newbie
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
/etc/profile (sh & bash)
~/.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 newbie
2009-08-27 16:23:19 UTC
Permalink
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
Post by Robert Hajime Lanning
Post by linux newbie
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?
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 -Centauri
Robert Hajime Lanning
2009-08-27 16:25:50 UTC
Permalink
Post by linux newbie
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
Loading...