SSH and a users .profile


 
Thread Tools Search this Thread
Operating Systems AIX SSH and a users .profile
# 1  
Old 01-08-2011
SSH and a users .profile

How do I get a command like "ssh Theuser@host date" to execute the /home/Theuser/.profile before executing the "date" command?
# 2  
Old 01-08-2011
try using ssh -t or . ~/.profile;date

Last edited by rbatte1; 11-16-2016 at 11:31 AM.. Reason: ICODE tags
# 3  
Old 01-08-2011
Thank you Frank
the -t works fine... now for part 2 please


if the profile is designed for tty input (ex Please specify test or production?") how can I


a) pass an answer via teh ssh command

and/or

b) request that ssh command ignore "reads"

Thanks again
# 4  
Old 01-08-2011
you can do either but if you want to read input from the user then -t would be required. you can also try the ssh -n option

or a better long term solution - put this in your .profile if you don't use -t
Code:
if tty -s
then
   echo "blah blah blah"
   read blah
fi

Code:
     -n    Redirects stdin  from  /dev/null  (actually,  prevents
           reading from stdin). This must be used when ssh is run
           in the background. A common trick is to  use  this  to
           run X11 programs on a remote machine. For example,

           ssh -n shadows.cs.hut.fi emacs &

           will start an emacs on shadows.cs.hut.fi, and the  X11
           connection  will  be  automatically  forwarded over an
           encrypted channel. The ssh program will be put in  the
           background. This does not work if ssh needs to ask for
           a password or passphrase.  See also the -f option.)


Last edited by frank_rizzo; 01-08-2011 at 11:57 PM.. Reason: add -n option
# 5  
Old 01-09-2011
I shall try your suggestions....
Smilie

---------- Post updated 01-09-11 at 01:06 PM ---------- Previous update was 01-08-11 at 11:03 PM ----------

Ok tried all teh above still no go

I can get commands to run before the shell is kicked off (~/.ssh/rc)
I can get environment variables set (~/.ssh/environment and sshd_config changes0

but I cannot get the user .profile to run for a user with a ssh Theuser@host date

even using the ssh options (albeit good) that Frank suggested.

For reasons that can get complicated (MVS is really shooting off the AIX command to AIX) I cannot use the option of physically executing teh users profile as in the suggestion

ssh Theuser@host ". ~/.profile;date"




ssh
# 6  
Old 01-09-2011
is date the real command your using or are you running a script or other program? If it's a script then I suggest sourcing the .profile within the script or put the logic that is in .profile in the script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Do not allow bypassing users .profile

Hello, I find out that there is a way from putty to pass a command to your shell when trying to log in to a server and bypass .profile. Actually you can do this if you open a bash shell. The command to bypass .profile is the following: ssh -t hostname "bash --noprofile" Is there a way to... (32 Replies)
Discussion started by: omonoiatis9
32 Replies

2. HP-UX

Create a new user from using existing users profile

Hello, Just wanting to know if it is possible. Also I am new to command line. I am running 5.1b, if that matters. Thanks in advance (10 Replies)
Discussion started by: bcha
10 Replies

3. UNIX for Advanced & Expert Users

ssh & load custom profile

i've created a custom profile that contains custom functions and alias' etc... it's called .jason_profile currently we ssh to the server then load the profile manually from the cmd line i.e . /home/jack/.jack_profile we want to be able to ssh and source the profile automatically but... (4 Replies)
Discussion started by: jack.bauer
4 Replies

4. HP-UX

Remote ssh execution and .profile issues

Greetings, i'm currently having issues in successfully executing a script from one server to other, and i'm cracking my nut in understanding why. Let's get started with the default info: Server A: briozzo@A:/home/briozzo $ uname -a HP-UX A B.11.31 U ia64 2787251109 unlimited-user license ... (3 Replies)
Discussion started by: nbriozzo
3 Replies

5. Solaris

Remove a given profile from a users account

Hi Guys, I was studying RBAC and I gave a profile to a user . I have not seen anywhere that shows how to remove the profile from the users account. Can anyone show me how to remove a given profile from a users account? Thanks alot guys. (2 Replies)
Discussion started by: cjashu
2 Replies

6. Shell Programming and Scripting

Users who desire to have their .profile executed must explicitly do so in the crontab entry. Why?

The .profile file should be read when the user logs in. So, there should be no need to execute .profile file again in a cron job (since the cron job is run after the user logs in). Doesn't the cron require login from the user. Then, from where does the cron execute? Please help!! (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

7. Shell Programming and Scripting

sourcing .profile for other users

Hi Team, Thank you for your time. i have a situation where the user IDs of the applicatio users have been locked down to Read only. Hence I am writing a script to invoke their old .profile every time they login. My problem is : when i run . $userpath/.profile from within the ksh script... (9 Replies)
Discussion started by: anitha111
9 Replies

8. UNIX for Advanced & Expert Users

How can I get sudo -u <username> to load that users profile on HP-UX

I am running a serverapplication on a HP-UX machine where I need to handle some of the commands as a specified user called "druser". When I log on as this user with the command; sudo -u druser -sit starts an instance of the shell as that user. However, it doesn't load that users .profile from... (1 Reply)
Discussion started by: ukiome
1 Replies

9. Shell Programming and Scripting

users with same .profile

guys i have a unix user (say "x") which is also an application owner ..thru this user i manage most (90 %) of my tasks related to application i.e application down/up,processes stop/start etc..in short i manage my "tuxedo" via this user.. now i want a new user to be created (on my name) which... (7 Replies)
Discussion started by: abhijeetkul
7 Replies

10. UNIX for Advanced & Expert Users

executing .profile with ssh

Hi, How do I get all my profile settings when connecting with ssh? (5 Replies)
Discussion started by: rein
5 Replies
Login or Register to Ask a Question