LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-23-2015, 08:58 AM   #1
tambi101
LQ Newbie
 
Registered: Jan 2013
Posts: 5

Rep: Reputation: Disabled
Question restrict commands to users


i have a user (john) in server user(john) should not execute any commands (except ssh,exit) can we do this with out scripting ! what is the best way to do this

regards
kiran
 
Old 06-23-2015, 09:01 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,841

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
probably you can configure restricted login shell for him, but actually you ought to specify better your requirements.
 
Old 06-23-2015, 12:50 PM   #3
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,490

Rep: Reputation: Disabled
Use sudo, (see man sudo).
http://www.sudo.ws/
 
Old 06-23-2015, 01:47 PM   #4
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
Quote:
Originally Posted by fatmac View Post
Use sudo, (see man sudo).
http://www.sudo.ws/
Surely confining what commands can be run with sudo only works if the user prefixes all his commands with 'sudo' or am I mistaken - wouldn't be the first time
 
Old 06-23-2015, 01:50 PM   #5
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
I guess you could set the users PATH to a folder that only has symlinks to ssh ( isn't exit a bash builtin? ), not too sure how you would stop the user from altering the PATH variable though.
 
Old 06-25-2015, 06:28 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Try a chroot acct ?
Or, build a small menu that only allows those cmds. As above, really need more details
 
Old 06-25-2015, 09:16 AM   #7
tambi101
LQ Newbie
 
Registered: Jan 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fatmac View Post
Use sudo, (see man sudo).
http://www.sudo.ws/
as i know sudo is for super user do , we can execute command as another user

---------- Post added 06-25-15 at 07:47 PM ----------

Quote:
Originally Posted by pan64 View Post
probably you can configure restricted login shell for him, but actually you ought to specify better your requirements.
thank you for your reply !
 
Old 06-25-2015, 09:20 AM   #8
tambi101
LQ Newbie
 
Registered: Jan 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Keith Hedger View Post
Surely confining what commands can be run with sudo only works if the user prefixes all his commands with 'sudo' or am I mistaken - wouldn't be the first time
thanks for reply ! yes you are mistaken again i tried on sudo already , super user do , we can execute command as another user if i was wrong please let me know
 
Old 06-25-2015, 10:03 AM   #9
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
rbash

Quote:
Originally Posted by Keith Hedger View Post
I guess you could set the users PATH to a folder that only has symlinks to ssh ( isn't exit a bash builtin? ), not too sure how you would stop the user from altering the PATH variable though.
Hard links there might work too. Alteration the path can be prevented with rbash or rksh as the login shell for that user. Just also make sure that the home directory and the files in it are not in anyway writable ( or owned by ) the user in question.
 
Old 06-25-2015, 02:41 PM   #10
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,490

Rep: Reputation: Disabled
Quote:
Originally Posted by Keith Hedger View Post
Surely confining what commands can be run with sudo only works if the user prefixes all his commands with 'sudo' or am I mistaken - wouldn't be the first time
I was under the impression that the O.P. wants the user John to have root power for ssh & exit. If he is given that power using sudo, they are the only programs that he can run as root.
 
  


Reply

Tags
linux system performance, new linux user, servers



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to block/restrict the inbuild commands smilemukul Linux - Newbie 5 04-02-2012 09:07 AM
How to restrict commands such as uname, w, and netstat? SentralOrigin Linux - Security 2 12-20-2011 04:48 PM
Restrict FTP commands vikas027 Linux - Server 6 04-19-2011 08:08 AM
Can sudo restrict certain commands? Thaidog Linux - Security 3 01-30-2009 11:24 AM
Restrict what commands users can use? jasone *BSD 1 11-30-2006 06:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:39 AM.

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