Operating System - HP-UX
1822469 Members
2404 Online
109642 Solutions
New Discussion юеВ

Re: rcp, rlogin ... without password prompt

 
SOLVED
Go to solution
Omar Alvi_1
Super Advisor

rcp, rlogin ... without password prompt

Hi,

I've edited the .rhosts file, and used SAM (Networking and Communication > System Access > Remote Logins), to allow me to use rlogin without being prompted for the password. For .rhosts, I put the remote and local system name and the user root. Same settings I tried from SAM, but still I'm prompted for password.

Initially, if I rlogin to myslef, I was prompted for password, but with same settings as for other systems I was able to get rid of the prompt.

The need for not being prompted is actually to use rcp. Is there any option or workaround that allows us to feed the password to rcp command.

Really appreciate any assistance

Thanks and Regards,

-Alvi
11 REPLIES 11
harry d brown jr
Honored Contributor

Re: rcp, rlogin ... without password prompt


What is the HOME for root?

grep root /etc/passwd | head | cut -d":" -f6

What are the contents of the root_HOME/.rhosts ?

It should be:
remotehostname root

You don't need to do anything special on the remotehost, other than actually being root to initiate the rcp.


live free or die
harry d brown jr
Live Free or Die
Steven E. Protter
Exalted Contributor

Re: rcp, rlogin ... without password prompt

I don't think sam uses .rhosts between machines. Perhaps i don't understand the issue.

You might wish to consider using Secure shell for the same functionality without the serious security implications of the r protocols.

http://software.hp.com/portal/swdepot/displayProductInfo.do?productNumber=T1471AA

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Elmar P. Kolkman
Honored Contributor

Re: rcp, rlogin ... without password prompt

One more thing to check: the mode of the file.
It should only be readable by the user, in your case root. (mode 600 or even 400, or -rw-------)
Every problem has at least one solution. Only some solutions are harder to find.
Omar Alvi_1
Super Advisor

Re: rcp, rlogin ... without password prompt

The home for root, I've been assuming is /. Therefore I've put .rhosts in /.

I've tried two combinations on both systems for .rhosts

systemname root

&

systemname

As for sam, I noticed that when I give login priviledges to the super user, and the option of not being prompted for password, the /.rhosts file is modified with only the system name added on a single line.

But I still get the password prompt.

-Alvi
harry d brown jr
Honored Contributor

Re: rcp, rlogin ... without password prompt


Are you rlogin'ing from another Hp system?


What about /etc/hosts.equiv??

live free or die
harry d brown jr
Live Free or Die
Rajeev Tyagi
Valued Contributor

Re: rcp, rlogin ... without password prompt

Alvi,

Confirm if /var/adm/inetd.sec file is not present on the server where you want to enable rlogin. If it is present All remote Service requests will be verified from this file. If this file is present for your rlogin you should define

login allow RLOGIN_CLIENT_IP
Mark Ellzey
Valued Contributor

Re: rcp, rlogin ... without password prompt

Alvi,

Also check for the /etc/securetty file. If this file is present, and has the word 'console' in it, you will not be able to remotely log into that host as root. You will be able to log in as a regular user, then su to root, but will not be able to directly log in as root remotely.

Regards,
Mark
Bill Hassell
Honored Contributor

Re: rcp, rlogin ... without password prompt

It sounds like everything is working correctly. The .rhosts file in each remote machine is what you need. Does remsh or rlogin work without passwords to the remote machines? Now remsh/rlogin/rcp don't make a lot of sense onto the same machine. Is that what is not working? You can get it to work by using the same .rhosts file on your local machine.

As far as where to put the file, it must reside in $HOME. NOTE: I did not say / or anything else. When you login, the value for $HOME is set (from the passwd file) to the correct location so you edit the file $HOME/.rhosts and it will be in the current user's home directory. / happens to be the default for root although it is a very bad default and should be changed.

.rhosts must be 600 permissions, owned by the user. So for root, .rhosts would be rw------- and owned by root. To test that remsh/rcp/rlogin all work without a password request, just ermove all lines in .rhosts and put in the single character: + which means: anyone from any system can use rcp/remsh/rlogin without a password.

Having said that, it is a VERY bad idea to have .rhosts for root. While it makes system maintenance easier, the possibility for a security breach is guarenteed. Consider reading up on ssh as a replacement for the "r" commands.


Bill Hassell, sysadmin
Omar Alvi_1
Super Advisor

Re: rcp, rlogin ... without password prompt

Thanks a lot everyone,

Finally the problem's been resolved.

I had the .rhosts configured properly, even sam made the since configuration

hostname root

Both my systems have 3 network interface cards; however etc hosts had only one entry for the remote system and three for itself. Once I modified etc/hosts on both systems to reflect all NICs, the password issue disappeared.

A few other pointers I learnt on the way

- $HOME/.rhosts is used to give super user access
- /etc/hosts.equiv is used for all other users.
- /etc/cmclnodlist can also substitute for $HOME/.rhosts

- /var/adm/inetd.sec .... what role does this have, while residing in var?
- Is there any good manual for ssh, i've downloaded and now i'll investigate
- Whats wrong with having rott's home @ /?

be assigning points soon.

Thanks a lot.

Regards,

-Alvi
Bill Hassell
Honored Contributor
Solution

Re: rcp, rlogin ... without password prompt

You wrote:

> $HOME/.rhosts is used to give super user access

True, but incomplete. Each user has their own home directory (to which the HOME variable is set) so the statement should read:

$HOME/.rhosts is used to give users on other systems access to the local system

> /etc/hosts.equiv is used for all other users.

/etc/hosts.equiv can indeed give users on other systems access to the local system but it is not the only method (see above). NOTE: hosts.equiv can be a serious security risk.

> /var/adm/inetd.sec

This file is service filter to allow or disallow certain IP addresses from accessing your local system. Although it resides in /var (for historical reasons), it is indeed a system-wide configuration file. Suppose you only want certain machines to access your system through telnet. You would then allow only those specific addresses (or range of addresses) to get through by editing inetd.sec. The man page for inetd.sec is very helpful.

> Is there any good manual for ssh?

The O'Reilley book for ssh is a good reference: http://www.oreilly.com/catalog/sshtdg/
although there are numerous quick reference docs posted here in the forums. I've attached Chris Vail's quick reference for SHH.

> Whats wrong with having root's home @ /?

/ is THE most dangerous directory in the system. If this is root's home directory, the most dangerous commands will destroy the entire system, requiring a complete re-installation. The most dangerous commands in Unix:

rm -r
mv
cp
chmod -R
chown -R

(there other dangerous commands that are not sensitive to the filesystem structures like dd and mediainit) So why is / very bad as root's HOME? Consider this fairly common mistake:

cd /temp
rm -rf *

If root just logged in, the computer is now being destroyed. The reason? The directory name is misspelled (/temp should have been /tmp) and the superuser forgot to look for a warning message (sh: /temp: not found.) after the cd command. The rm -rf will silently remove *EVERY* directory and file on the entire computer (or at least until HP-UX crashes) and if bad permissions were given to access NFS-mounted directories, the command will also destroy files and directories on remote computers. Only your CDROM is safe.

cd is often overused by root. Root is too powerful for casual use so if you need to remove a directory, *always* use a fullpath. Repeat: always use a fullpath. In the above example, changing the rm command from

rm -rf *

to

rm -rf /temp/*

would have done nothing and reported an error message. Similarly, a common sysadmin mistake is not understanding pattern matching and regular expressions. For example, to remove a user's files, novice sysadmins might do this:

cd /home/billh
rm -rf *

But then find out that .profile and other . files are still there. So they will issue this command:

rm -rf .*

Again, a major mistake. .* says: match all files and directories that start with . and have ZERO or more characters following. No problem with .profile, .sh_history and so on, but as an exercise, try this command in your $HOME directory:

echo .*

The first two filenames that are matched will be . and .. which is a big surprise to a newbie sysadmin. Yes, .. is a real directory and it happens to be the parent, in this case, /home. So the rm command will start recursively removing every directory and file in .. (/home) thus destroying all the user files. This isn't nearly as bad as / but certainly not a nice way to start the day. Whenever I am about to use a recursive rm (or mv, cp) command, I'll put echo in front to see exactly what the shell sees:

echo rm .*

Hint: you can avoid . and .. directories by using [!.] which is a character class to exclude (not match) the . as a character string. Try this:

echo .*
echo .[!.]*

and you'll see the . and .. directories disappear from the list. Of course, there are always obscure exceptions, in this case, any file or directory that starts with 2 dots (ie, ... or ..abc) will be missed. But that's a small consequence to the possibility of removing every user's HOME directory.

I ALWAYS alias the 3 commands for file destruction to have the -i option in root's .profile:

alias rm="/usr/bin/rm -i"
alias mv="/usr/bin/mv -i"
alias cp="/usr/bin/cp -i"

So the first thing that a sysadmin will do in setting up a new system, even before adding patches and applications, is to move root's HOME. Don't worry, HP-UX is not alone with this setup--many other flavors of Unix have the same default HOME for root and they all need to be fixed to control the "oops" factor. The most common technique is:

umask 077
mkdir /root
vipw

The command vipw is the recommended editing method for changing the passwd file. Not only does it save a lot of keystrokes (vipw versus vi /etc/passwd) but it creates a lockfile so another root user won't accidently edit the same file. In vi, change the second to last field from :/: to :/root: and then save the result. While leaving a root login window open, try logging in as root in another window. If all is well, you can type pwd in the current window and you'll see /root. Now you can move all files (not directories) into /root. NOTE: Some bad applications may require ordinary files in / so make sure you know if there are such files in /. Naturally, you can always move them back from /root to / if necessary.

All good questions. I'll be covering a lot of these techniques March 22 in Amsterdam (actually, the HP office in Amstelveen).


Bill Hassell, sysadmin
John Tang_3
Occasional Visitor

Re: rcp, rlogin ... without password prompt

I had the same issue. I added every single NIC in the hosts file on both systems, but still had the password prompt. I have to add all alias of every IPs of org system to the target .rhosts file to resolve the issue.