I do the following many times a day
I login to a server via ssh as
user1,
I then dosu -to becomeroot,
then I dosu --login user2to becomeuser2
Is there a way to tell su to go to user2 directly from user1?
Note:
user21 does not have a password. user2 is named different at different times. (apache, liferay, solr, ftp, ...)
Note2:
user1 is not trusted with sudo it's a general purpose account used mainly to access logs. It doesn't even have a password, access granted only with a sshkey only.
Note3:
NO solutions that means any modification of the remote computer allowed. I have 30+ servers that I admin.
1 If you are curious it's the user an application runs as (tomcat, apache, jetty or similar)
su - -c "su - user2"– Keith Apr 21 '11 at 8:19