$USER is not set in remsh but works fine via ssh login


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers $USER is not set in remsh but works fine via ssh login
# 1  
Old 01-18-2011
$USER is not set in remsh but works fine via ssh login

1)
ssh a@b
echo $USER it display the correct value as a (even though i have not defined it in .profile)

2)
remsh b -l a
echo $USER it does not display the value as a (variable is not set

any idea why $USER variable is not initialized when i login via remsh or rlogin but shows the correct value via ssh login

i guess there are some system profile /shell variables which generate these values and it is not getting initialized by remsh/rlogin

can someone pls suggest a solution for this ?

thanks
# 2  
Old 01-18-2011
Often variables such as $USER are set in the global profile. ssh runs these global profiles when the user logs on. remsh, however, doesnt. Most shells, however will allow you to run then as a login shell, so for instance if you were running "/usr/bin/env" try running something like:
Code:
remsh b -l a "/bin/sh -l -c /usr/bin/env"

(paths and arguments to your shell can vary on different O/S so I would check your man pages)
# 3  
Old 01-18-2011
seems /usr/bin/env is already getting initialized by remsh
i checked the variable defined in this is getting initialized

echo $LOGNAME

still i am not able to see the value of $USER perhaps its coming from some other file
# 4  
Old 01-18-2011
I presume from the use of "remsh", that this is a HP-UX machine ? If it is, what version is it ? I believe HP-UX 11.11 and below had a remshd that didnt use the normal methods of creating a user session (namely by calling PAM - Pluggable Authentication Modules).

Perhaps instead of using remsh you could use ssh with a command (you can set ssh up to not ask for passwords if needed) - this would also be much more secure...remsh, rsh and rlogin are notoriously bad at security.
# 5  
Old 01-18-2011
HP-UX B.11.23
unfortunately i need a fix in case of remsh and then in future might change to ssh where its working fine ..
# 6  
Old 01-18-2011
USER wouldn't be initialized by any global file -- how could a global file know which user? It should be initialized by the login system, something remsh apparently does an end-run around. You might have to just set it yourself.
# 7  
Old 01-18-2011
Some of the old UNIX did initialize USER from the ownership of the tty. This is where the issue lies. remsh/rsh doesnt allocate a tty, and so cant do this. Other applications that either use "login" or correctly use the PAM method of authorization set default environment variables directly and so dont have this issue.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

How to set a non-login non-interactive shell for a user?

I am sorry for creating a new topic after my previous inquiry was closed, but I tried and tried and I do not know how to edit my previous post. This is not exactly any homework, this is one of 40 questions we were expected to prepare for one of the labs. I searched and read what I could and still... (4 Replies)
Discussion started by: me_me_me
4 Replies

2. Homework & Coursework Questions

How to set for a user a non-login shell?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am a root in a Unix system. My shell is bash. 2. Relevant commands, code, scripts, algorithms: How to set... (1 Reply)
Discussion started by: me_me_me
1 Replies

3. HP-UX

How to set PATH variable for all HP-UX users when they login using ssh?

Hello friends, I need to set PATH variable for all HP-UX users. I tried to implement it using /etc/profile and /etc/sshrc both none of them work. I don't see sshrc file anywhere. Please advise! TIA (4 Replies)
Discussion started by: prvnrk
4 Replies

4. UNIX for Dummies Questions & Answers

C-program works fine interactively, but not on the SGE server

Greetings, I have a C-program that is made to implement a hidden Markov model on an input file. The program is very memory intensive. I've installed it on my local server where I have an account and it compiles fine. The way they have the server set up is that you can either work... (1 Reply)
Discussion started by: Twinklefingers
1 Replies

5. Solaris

HOW to set unlimited login attempts for user in Solaris?

Hi Admins, HOW to set unlimited login attempts for user in Solaris ? And do I need to insatll any packages before doing this? Thanks. (1 Reply)
Discussion started by: manalisharmabe
1 Replies

6. Shell Programming and Scripting

Not the correct output, works fine via CLI, not inside the script.

Guys, I need you help please. The script below is not working correclty for checking via a awk/if statement . Can you tell me what i am doing wrong in the script code "if($1 == "$RETENTION_LEVEL") " Syntax RETENTION_LEVEL=`echo $LINE | cut -f2 -d" "` echo " ==============... (4 Replies)
Discussion started by: Junes
4 Replies

7. Shell Programming and Scripting

Script works fine but not with crontab

Hello All, This is driving me nuts. Wrote a very simple script (it's in csh so sorry about that). Just something very simple though. Here is the catch. Works great from command line sometimes. Other times it runs no errors or anything but I never receive an email. Never runs from crontab... (6 Replies)
Discussion started by: jacktay
6 Replies

8. AIX

SSH login hangs, serial console works

Server, running AIX 6.1 developed strange problem when logging in via SSH -- ssh client hangs without any error. It is possible to run commands on server, using ssh ("ssh servername ls -l" is OK) It is possible to log in normally, using serial console connected to server. It was possible to... (2 Replies)
Discussion started by: ivar.zarans
2 Replies

9. Shell Programming and Scripting

Cron job fails, but works fine from command line

I have a very basic script that essentially sends a log file, via FTP, to a backup server. My cron entry to run this every night is: 55 23 * * * /usr/bin/archive_logs The script runs perfectly when executed manually, and actually worked via cron for about three weeks. However, it mysteriously... (3 Replies)
Discussion started by: cdunavent
3 Replies

10. Shell Programming and Scripting

Script works fine until I | more

Hello all, This beats me. I have a script that executes some commands and redirects their output to some text files that I will parse. The commands are along the lines of: dsmadmc -id=admin -pa=admin -outfile=/home/tools/qlog.txt q log f=d If I just run the script it works. If I execute... (2 Replies)
Discussion started by: Skovian
2 Replies
Login or Register to Ask a Question