- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Transfer files using sudo
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2008 05:22 AM
06-03-2008 05:22 AM
Transfer files using sudo
This solves the problem of logging in as a generic user to the system. However, from time to time there will be a need to transfer files (using scp, sftp or whatever) to or from a system using a *generic* user. For example assume you want to transfer a very large file to your PC which can only be accessed by the root user.
How do you satisfy that kind of needs in real life?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2008 05:28 AM
06-03-2008 05:28 AM
Re: Transfer files using sudo
> real life?
Fix the contradiction in the requirements?
Correct me if I'm wrong, but you seem to want
a non-root user to be able to access a file
"which can only be accessed by the root
user."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2008 05:33 AM
06-03-2008 05:33 AM
Re: Transfer files using sudo
Let me be more clear.
User "user1" is a system admin and can use "sudo -i" to get root shell (so he/she can do anything a root can do without knowing the actual root password). How can "user1" transfer a file which can only be accessed by root? The option of chmod/chown or cp the file to give it "user1" ownership is not acceptable, considering it is a very large file that needs to be kept secure.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2008 06:00 AM
06-03-2008 06:00 AM
Re: Transfer files using sudo
Note: In this example I'll use oracle (note: this is very high level);
1) create key on source system (ssh-keygen) as oracle (this will be in ~oracle/.ssh)
2) copy public key to destination system and put in oracle's ~oracle/.ssh/authorized_keys file.
Now you can scp files from source->destination as oracle without needing the password.
Note: when creating the key it will give the option of creating a pass phrase. I would recommend doing this. If you need to automate your process you can use an ssh key agent to help with the pass phrase.
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2008 06:02 AM
06-03-2008 06:02 AM
Re: Transfer files using sudo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2008 07:14 AM
06-03-2008 07:14 AM
Re: Transfer files using sudo
> [...] considering it is a very large file
> that needs to be kept secure.
It's easier to consider requirements like
this when they're known. Perhaps you should
make a list. SSH access as "root" may allow
a non-root user to do more than copy files,
too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2008 07:25 AM
06-03-2008 07:25 AM
Re: Transfer files using sudo
> [...] How can "user1" transfer a file which
> can only be accessed by root?
That's clear. It's impossible. Either
"user1" _can_ access the file, or else only
"root" can can access the file. They can't
both be true. There are various methods by
which "user1" might access a well-protected
file, but there's no way to access a file
which can't be accessed.
If you wish to give "user1" read access to a
file, this could be done using an access
control list. "man 5 acl".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2008 07:44 AM
06-03-2008 07:44 AM
Re: Transfer files using sudo
The user "johnthedba" will do anything "oracle" can do including copying files in and out of the system. The "ssh keys" (mentioned above) is an option; however it is very slow while copying file over a Gbps LAN environment. The user "johnthedba" will copy large oracle export files to or from other systems. These files are owned by "oracle" and nobody else will have read or write access to these files, including the directory they are stored. Currently we are using ftp because it is much faster than scp or sftp.
I am considering using an ssh and netcat (nc) combination. Any other ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2008 09:21 AM
06-03-2008 09:21 AM
Re: Transfer files using sudo
As for file transfer, you can use a specific command line in sudo as oracle for this user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2008 09:27 AM
06-03-2008 09:27 AM
Re: Transfer files using sudo
ssh youruser@yourserver "sudo cat /something/secure" >local_copy
As for keys... they're a good solution in some situations, but letting users have ssh keys for generic accounts is almost the same as giving out the password. In both cases there is "something" that will give anybody who has it the ability to act as that user. Correctly controlling access while using ssh keys in this manner will probably be difficult.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2008 09:29 AM
06-03-2008 09:29 AM
Re: Transfer files using sudo
I know it is not convenient, but the price of security is inconvenience. You have to pay the piper at one point. So, pick your poison... :)
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2008 12:19 PM
06-03-2008 12:19 PM
Re: Transfer files using sudo
> the *specific* user "johnthedba" full
> "oracle" user priviledges without giving
> the password of "oracle". [...]
If a user has 'full "oracle" user
privile[d]ges', why not give him the "oracle"
account password, too? How much more damage
could he cause that way?
Methods like ACLs and "sudo" are used to give
and _restrict_ special privileges. If you
really want to give away the whole store, why
not hand over the keys and the deed?
On the other hand, if you want to allow some
user(s) to be able to perform certain limited
tasks which require special privileges, then
selecting the best approach might require
defining exectly what those tasks are.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2008 10:02 PM
06-03-2008 10:02 PM
Re: Transfer files using sudo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2009 01:04 PM
03-18-2009 01:04 PM
Re: Transfer files using sudo
oracle:
sudo -u oracle scp user1@remotesystem:/path/file .
When the file lands on the localhost, it will land as being owned by oracle.
root:
sudo scp user1@remotesystem:/path/file .
When the file lands, it will be owned by root.
Assumptions made here is that for the oracle example, that user1 has read access to these files you are trying to copy. In our environment, all files are owned by oracle:dba and our dba admins are all in the dba group with at least 640 permissions.
It is very possible for files that can only be accessed by root to be access by normal users with sudo (given that the normal user is given full sudo access). Without running sudo, the same user1 will not have access to that file.
Hope this helps.
-fng