hankknight
asked on
changing user for command
Hello.
I want to log in with SSH as "webuser" but I want to do the following:
cp -pr /home/web/mysite.com/html/
as the user "hank" password "mypassword"
Can this be done? If so, how?
Thanks!
To log on to a server as a different user
ssh -l username server
or
ssh username@server
Im not 100% on what you are trying to achieve are you coping files from one server to another? Or locally copying files once logged in on the remote computer?
If its a local copy the syntax is correct if you are copying from a remote comp to local you need to use
scp -rp user@remote:/path/to/files user@local:/path/to/files
ssh -l username server
or
ssh username@server
Im not 100% on what you are trying to achieve are you coping files from one server to another? Or locally copying files once logged in on the remote computer?
If its a local copy the syntax is correct if you are copying from a remote comp to local you need to use
scp -rp user@remote:/path/to/files
ASKER
Thanks!
What I am actually trying to accomplish is to get a web script to copy local files to a different local directory. Because of this there must not be a password prompt.
Looks like sudo should do what I need.
http://www.courtesan.com/sudo/man/sudo.html
but I can't figure out how to enter the password for "hank"
sudo -u webadmin -p %U mypassword cp -pr /home/web/mysite.com/html/ source /home/web/mysite.com/html/ dest
does not work.
How can I proporly pass the username and password values?
Thanks
What I am actually trying to accomplish is to get a web script to copy local files to a different local directory. Because of this there must not be a password prompt.
Looks like sudo should do what I need.
http://www.courtesan.com/sudo/man/sudo.html
but I can't figure out how to enter the password for "hank"
sudo -u webadmin -p %U mypassword cp -pr /home/web/mysite.com/html/
does not work.
How can I proporly pass the username and password values?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sudo is probably better, with the NOPASSWD option, man sudo for details