Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have this command:

ssh user1@192.168.242.16 'sudo -u oracle fgrep ...'

can someone explain me how this command works ? I just know that someone is connecting to remote computer as user1 and want to run some command as oracle. He can do this ? Need user1 some privileges and why when I run this command I need to set password of user1 and not oracle ?

thx

share|improve this question

migrated from stackoverflow.com Dec 5 '12 at 21:18

This question came from our site for professional and enthusiast programmers.

3 Answers 3

With sudo you can run stuff as any user you like.

This command will work if user1 is added to sudoers with NOPASSWD which means user1 can perform commands with sudo and is not required to enter his password when doing so

share|improve this answer

ok this command is two parts:

ssh user1@192.168.242.16

connects to the remote box and logs in as User 'user1'

the second command starts with 'sudo', a utility that allows a user to temporarily exercise root authority. the ability to run sudo is a right granted to a user, so a user without sudo capability will not be able to run sudo at all.

Sudo prompts a user to input their own password. this ensures that the user really wants to run the job as root and that they are the authorized user for that account. that way, only a sudo-capable user can take root, and they are forced to prove that they are who the system thinks they are.

share|improve this answer

It is just a "chained" command:

  1. authenticate against the remote system as user1
  2. invoke on the remote system a command with effective user oracle

Important is to understand why this is used:

  1. For security reasons some accounts are not accessible via ssh. This can be done by configuration (see below).
  2. The remote user account has simply no password or has no usable entry in .ssh/autorized_keys.

Note - deny ssh access for specific accoutns

In the most default configurations the root account is blocked for ssh. This is normally done in /etc/ssh/sshd_config with the option:

PermitRootLogin no

In addition you can specify there the options DenyUsers, AllowUsers, DenyGroups, and finally AllowGroups.
For detailed informations see man sshd_config.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.