Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

my company has multiple domains and I log into my local machine with one set of credentials, but often when accessing certain network resources I need to use a different set of credentials. In Windows I would use RunAs where I have the option to run the entire process as under a different set of credentials or I could tell it to only impersonate the other user over the network (runas /netonly).

Is there something like this in Linux?

share|improve this question

2 Answers 2

up vote 22 down vote accepted
$ sudo -u <username> <command>

That will run the specified command as the user specified. It's not an exact drop-in for Windows' RunAs function, though, as that incorporates Kerberos authentication as well as for tasks that connect to remote hosts.

share|improve this answer
    
@Mark: look into the different pam authentication modules to add network authentication support (pam_krb5 and pam_ldap are a good place to start) –  photoionized Apr 26 '11 at 18:44
    
ok, but when I try sudo -u [domain2]\[username] it tells me 'unknown user: [domain2][username]' –  Mark J Miller Apr 26 '11 at 19:07
    
@Mark - that would be becuase by default, linux hosts know nothing of your AD/Windows environment. It's certainly possible to configure linux to use AD for authentication, but that's a separate question. –  EEAA Apr 26 '11 at 19:10
    
you're right, I've awarded the points and I'll post a new question. –  Mark J Miller Apr 26 '11 at 19:16
2  
@Mark Sounds good. Before you post a new question, though, search through old ServerFault questions. There are scads of them relating to integration of linux and Windows. –  EEAA Apr 26 '11 at 19:21

sudo or su

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.