LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-27-2007, 07:52 AM   #1
eyt
Member
 
Registered: Sep 2003
Posts: 76

Rep: Reputation: 15
assign user with root privilege and permisssion to access system files


Hi all,

I want to write a cron job script to backup up the system files of the remote machine through ssh.

As the remote machine does not allow ssh root login for security reason, how to create an ordinary account that has root
privilege and permission so that this account can access and read those files that required root privilege and permission
 
Old 07-27-2007, 08:04 AM   #2
Master Fox
Member
 
Registered: Aug 2004
Location: UK
Distribution: Arch (Duke / Desktop), FreeBSD 6.1 (Home-Dev server)
Posts: 131

Rep: Reputation: 15
Why dont you log in normally, and then "su" and then issule the crontabs? This way the crontabs are running from the root user but I've given you below how to make a new user with root

create a new user

type the command: "adduser", if that doesn't work, useradd -m <username>
set the password: passwd <user>
set the group: gpasswd -a <username> root

and the user should have root access, allowing it to read and write root files. - This does set a secuirty risk to the operating system.
 
Old 07-27-2007, 08:40 AM   #3
eyt
Member
 
Registered: Sep 2003
Posts: 76

Original Poster
Rep: Reputation: 15
Hi Master Fox,

I don't get what is mean about login normally and then "su" and then issue crontabs.
The script will run in the local machine and will connect to remote mahine through ssh. The sample script will be as follows:

cd /home/backup
ssh user@remotemachine "cd / ; tar cf - etc"|tar xvf -

( The user need root privilege and permission to access the remote machine /etc directory )
 
Old 07-27-2007, 09:08 AM   #4
Master Fox
Member
 
Registered: Aug 2004
Location: UK
Distribution: Arch (Duke / Desktop), FreeBSD 6.1 (Home-Dev server)
Posts: 131

Rep: Reputation: 15
well how I mean, "su" is a super user command, it allows you to log in as root from a normal user account.

[paw-fox@ ~]$ su
Password: (your root password)
[root@ /]#

Whatever I do when logged into SU will run as root, so if I deicded to do crontab it would be running from root. if you used your script: "crontab -e 30 18 * * * ssh user@remotemachine "cd / ; tar cf - etc"|tar xvf -" (I know it woudn't work) it would run the process given as root allowing full acess to the system

If you can already login as a normal user (I assume you can) use the SU command

Last edited by Master Fox; 07-27-2007 at 09:15 AM.
 
Old 07-27-2007, 11:01 AM   #5
eyt
Member
 
Registered: Sep 2003
Posts: 76

Original Poster
Rep: Reputation: 15
I run as you told as follows:

I logged in su and run as root and run the script, testScript

root> ./testScript

It gives the following error:

crontab: usage error: no arguments permitted after this option
usage: crontab [-u user] file
crontab [-u user] [ -e | -l | -r ]
(default operation is replace, per 1003.2)
-e (edit user's crontab)
-l (list user's crontab)
-r (delete user's crontab)
-i (prompt before deleting user's crontab)
-s (selinux context)

***************************************************************
Details of testScript script as follows:
#!/bin/sh

source ~/.keychain/localmachine-sh
cd /home/backup
crontab -e 50 11 * * * ssh user@remotemachine "cd /; tar cf - etc"|tar xvf -
*****************************************************************

Any idea what went wrong
 
Old 07-27-2007, 11:38 AM   #6
Master Fox
Member
 
Registered: Aug 2004
Location: UK
Distribution: Arch (Duke / Desktop), FreeBSD 6.1 (Home-Dev server)
Posts: 131

Rep: Reputation: 15
I would have to pass, my scripting abities are quite low when it comes to bash scripting, I guess another way would be do all your jobs would be placing it in a file

---
cd /home/backup
tar cf - etc"|tar xvf -
---
then use crontab to run that script, so
"crontab -e 50 11 * * * bash script.sh"
but otherwise I can't help you any more.
 
Old 07-27-2007, 12:02 PM   #7
eyt
Member
 
Registered: Sep 2003
Posts: 76

Original Poster
Rep: Reputation: 15
It works now. Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
user access to files owned by root jonfa Linux - General 2 07-09-2007 11:58 AM
how do I access my user files from the root? bobo333 Linux - Newbie 3 08-29-2006 02:24 PM
Giving a user (not a root) an access to some system commands asschay Linux - Newbie 8 09-08-2005 05:53 PM
Why root has no privilege to access some directories ymei Linux - General 4 10-08-2003 08:14 AM
How to assign directory access to a user linuxfans Linux - General 7 04-16-2003 12:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration