Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this command:

ssh user1@ '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 ?


share|improve this question

migrated from Dec 5 '12 at 21:18

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

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@

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .