scp with a sudo user


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers scp with a sudo user
# 1  
Old 06-30-2008
scp with a sudo user

Morning guys, I'm hoping you can advise me as to whether or not the following is possible.

Is there a way of firing off an scp command with a sudo user as the user?

e.g. I am logged onto server1 as smith, but want to pull files from server2 that I can only read as sudo jones.

In my mind it would be something like:

Code:
scp sujones@server2:/files/under/here/* .

But that doesn't work. Any ideas?
# 2  
Old 06-30-2008
Sure does it work if it's set up correct ie. jones must be allowed to write in the directory on server1 and the sudoers is configured correct. Best to exchange keys so you don't have trouble with passwords, ie. when using keys, be sure you don't enter a password when creating them.

Just saying "It doesn't work" is a bit hard to debug. Error messages help the people that can't see your screen a lot.
# 3  
Old 06-30-2008
When I run that command it asks me for the "sujones" password, but doesn't accept the one I put in. I assume it is looking for a user called "sujones" as opposed to "sudo sujones".
# 4  
Old 06-30-2008
su and sudo are different tools.

With sudo you set up a sudeoers file with the command visudo and edit it to your needs. When invoking it, you will have to use some syntax like
Code:
sudo -u jones <cmd>

sudo has a good documentation page in the www.

When you go for su, you don't have to setup a config file like with sudo, but afaik, only root can su to any user without being prompted for a passwd. If this is no problem, you will use
Code:
su - jones

To fire off a cmd you might use something like
Code:
su - jones -c "<cmd>"

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to scp File from root user in one server to say crt user in another server and avoid password?

Can someone help in writing some script through which I can transfer file (scp) from root user in abc server to crt user in hfg server and can give the crt user password in script itself so that it doesn't prompt me every time for password (4 Replies)
Discussion started by: Moon1234
4 Replies

2. AIX

Sudo to other user

Hello All, I am trying to grant sudo privileges to a set of users (say tom and jerry) to sudo to another set of users (jim, harry). This is because we don't want to disclose the password of jim and harry. I did defined the user_alias and runas alias. %wms ALL = (USR) /usr/bin/su -, where wms... (7 Replies)
Discussion started by: ibmtech
7 Replies

3. Shell Programming and Scripting

sudo su - user not working

Hi All, I need your expertise to solve my problem, my account has permission to make sudo and su but when I try to switch user in a shell, it does not work with following message: "Sorry, user jmbeltra is not allowed to execute '/usr/bin/su -c echo HELLO THERE - oracle' as root on dbbr1k01" I... (4 Replies)
Discussion started by: Axtel
4 Replies

4. UNIX for Dummies Questions & Answers

Sudo for Non-Admin User

Can a user who is not an admin be added to sudoers to allow them to elevate to root and run administrative tasks only from the command line by using sudo, but not be able to perform administrative tasks in any other capacity? ---------- Post updated at 11:07 AM ---------- Previous update was at... (1 Reply)
Discussion started by: glev2005
1 Replies

5. UNIX for Dummies Questions & Answers

scp + sudo

There are two servers, server A and B. User alpha has read/write permission for server A but can only logon to server B . For read write permission on server B user alpha has to use Sudo -u beta command I want to copy a file from server A to server B. How can I combine sudo and... (2 Replies)
Discussion started by: chrisjones
2 Replies

6. UNIX for Dummies Questions & Answers

sudo su - USER ??? How to??

Hi folks, Here is my question of the day 8-) I have to provide the ability to sudo su - orapd2 & sudo su - pd2adm for the following people User A, B, C, D which all of them are part of the group staff. orapd2 and pd2adm are also users. Users A, B, C, D should not type the password for... (2 Replies)
Discussion started by: 300zxmuro
2 Replies

7. UNIX for Dummies Questions & Answers

sudo user

I am trying to run a command from different user on my server. However when i execute the command it asks for password can you please help. when i use this command to switch user no password is required 1) sudo su - bilbtf42 when i use 2) sudo su - bilbtf42 cp file1 direcotry1/file1 ... (3 Replies)
Discussion started by: blackeyed
3 Replies

8. AIX

sudo user access

I have installed sudo on AIX 6100-04 and want to know how do I set it up for a user to be able to run only some commands? I want to give the user the rights to only cd to certain directories and run the ls command to name a few? Are there any issues with running sudo when the user is forced to... (2 Replies)
Discussion started by: daveisme
2 Replies

9. UNIX for Dummies Questions & Answers

Using sudo scp -r – can't get everything copied though

I want to copy a folder and all its contents of ~700GB from a computer to another. I've tried sudo scp -r directory/ admin@host:directory but the result is that the copied folder is about 2GBs smaller than the original. I checked the shell for errors and found some "file doesn't exist" errors.... (2 Replies)
Discussion started by: MJH
2 Replies

10. UNIX for Advanced & Expert Users

scp and sudo?

I'm using AIX and I have the following issue: I need to copy configuration files from one server to another but I don't have root rights. All I can do is use sudo to change to the application owner. Permissions are such that I can't copy these files from my home, not even via /tmp to the... (3 Replies)
Discussion started by: rein
3 Replies
Login or Register to Ask a Question