1753464 Members
4697 Online
108794 Solutions
New Discussion юеВ

Re: su with password

 
eng.Zohair
Esteemed Contributor

su with password

i need to switch user without enter password. with other words i need to switch user and wirte password in the command "su" itself. is any parameter do that ?

Regards,
9 REPLIES 9
avizen9
Esteemed Contributor

Re: su with password

Hello,
if you are super user root and will try to switch any other user it will not ask password , thanks,
Suraj K Sankari
Honored Contributor

Re: su with password

Hi,

A normal user can't do "su" without passwd. if you are super user then you can "su" switch user without passwd.

Suraj
Kranti Mahmud
Honored Contributor

Re: su with password

Hi Zohair,

A non-root user need password to do "su". But a root user can "su" switch user without passwd.

The following link may help you:

http://www.unix.com/unix-advanced-expert-users/95304-su-command-without-password-prompt-non-root-account.html

Rgds-Kranti
Dont look BACK as U will miss something INFRONT!
smatador
Honored Contributor

Re: su with password

Hi,
Ok, it's yet said user root can do what do you want.
Now, if you want an userA to do a su userB without or with a passwd in the command it's perhaps because you want an userA to launch a command or a script own by userB. If it's the case, it's better to see sudo command.
http://hpux.connect.org.uk/hppd/hpux/Sysadmin/sudo-1.7.1/
you could take it on the internet express cd too
http://h71019.www7.hp.com/hpux11i/cache/324414-0-0-0-121.html
If you want to make a script with su user and put the passwd, you could play also perhaps with the command expect.
Hope it helps
Sajjad Sahir
Honored Contributor

Re: su with password


Dear zohair

as a security while trying other users for su
it should ask passwd
in root case it will not ask.

but if u want other user also u can make(by making userid 0) but it is wrong policy
every time other than root user should ask
passwd.

thanks and regards

Sajjad Sahir
johnsonpk
Honored Contributor

Re: su with password

Hi,

There is no option to give password along with su command.How ever you can use sudo with NOPassword option

For sudo http://www.sudo.ws/sudo/download.html

If you have ssh installed on your server,then below method can be used for switching user with out password

for you have users called USERA and USERB on server TEST then

#su - USERA
#ssh-keygen -t rsa
it will create private and public keys under $HOME/.ssh/
#su - USERB
#mkdir .ssh
#cat /home/USERA/.ssh/id_rsa.pub >> /home/USERB/.ssh/authorized_keys


now you can login as USERB from the USERA@ localhost

USERA@TEST>$ ssh USERB@TEST

Johnson
eng.Zohair
Esteemed Contributor

Re: su with password

Thanks a lot guys
Sajjad Sahir
Honored Contributor

Re: su with password

Dear Zohair

Please assign the points

thanks and regards

Sajjad Sahir
Kranti Mahmud
Honored Contributor

Re: su with password

Hi Zohair,

U shud assign points as we gave you solution by wasting our time...u shud respect this.

Rgds-Kranti
Dont look BACK as U will miss something INFRONT!