Qiang has asked for the wisdom of the Perl Monks concerning the following question:

dear monks,
I have a script which log in a remote box using Net::SSH::Perl.

this script belongs to user lp and lp group. if i run this script as root, it runs fine. however i need to run this script as user 'lp' ( i guess it's the line print for short). however i got error that

mkdir /root/.ssh: Permission denied at /usr/lib/perl5/site_perl/5.8.0/Net/SSH/Perl/Util/Hosts.pmline 50

i am not sure why it is trying to touch root. any thoughts ?

Qiang update: i just chown this script to a common user, it runs fine for this user.

Replies are listed 'Best First'.
Re: net::ssh::perl permission problem
by Roger (Parson) on Oct 27, 2003 at 02:59 UTC
    Have you checked the password & home directory configurations for the lp user yet (/etc/passwd)?

    User lp is not a real user, I don't know where its user home directory is set to on your system.

    Now come to the secure shell (ssh) part. Secure shell requires Private-Key for the user (that is running your script) to be stored under ~user/.ssh. If this directory has not been setup (using ssh-keygen) then it will attempt to create one for you.

    I am guessing that the home directory for lp might be set to /root on your system. Your perl script is attempting to access that directory. And of course that will fail because only root can access the /root/.ssh directory (/root/.ssh directory is owned by root and only accessible to root).

    Another possibility is that the environment for lp user is not setup properly because it is not a real user. This is often the case on my systems as the environment for setuid users are always kept to the bare minimum.

      you pretty much nailed it.

      use Env; and set the HOME directory to /tmp in the script solves the problem.