Jan 10, 2026 - 07:08 AMDeutsch | English
Hello unlogged user [ Register | Log in ]

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
garfield168
Post subject: su passworteingabe im Skript  PostPosted: Sep 06, 2005 - 11:03 AM



Joined: Mar 11, 2004
Posts: 89

Hallo,
ich habe mal wieder (bzw. eigentlich immer noch) ein Problem.
Hier in der Firma soll ich ein Linux Skript neu anpassen. Im Skript wird mit su zu einem anderen User gewechselt (dafür ist Passworteingabe nötig, da ich kein root bin).
Das Problem ist nun, dass das ganze automatisiert ablaufen soll (als Nightlybuild). Ich kann die Rechte nicht verändern, dürfte aber z.B. das Passwort im Klartext ins Skript schreiben. Ich weiss nur nicht wie.
In einem vorherigen Thread hatte ich es auch schonmal erwähnt aber es kam keine echte Lösung bei raus (nur Hinweis, dass es vielleicht mit sudo gehen könnte aber ich habe es mit sudo nicht geschafft).

Bitte Hilfe!
 
 View user's profile Send private message  
Reply with quote Back to top
Boregard
Post subject:   PostPosted: Sep 06, 2005 - 11:32 AM



Joined: May 20, 2005
Posts: 323
Location: Niedernberg
Müsste doch gehen mit:
Code:
su username <<EOF
passwort
EOF

Im script natürlich...
 
 View user's profile Send private message  
Reply with quote Back to top
Boregard
Post subject:   PostPosted: Sep 06, 2005 - 11:55 AM



Joined: May 20, 2005
Posts: 323
Location: Niedernberg
Ich habs mal getestet, und auf die schnelle nur mit 2 Scripten hinbekommen.
Ein Script, das als anderer User ausgeführt werden soll, und ein script, das den Benutzerwechsel macht.
Hier das Script testfunc.sh
Code:
#!/bin/sh

echo
echo -n "Ich bin "
whoami

Und hier das Ausführscript testsu.sh:
Code:
#!/bin/sh

su -c /home/boregard/testfunc.sh<<EOF
myrootpwd
EOF

echo -n "Und ich bin "
whoami

Beide ausführbar gemacht und dann ausgeführt:
Code:
testsu.sh
Password:
Ich bin root
Und ich bin boregard

Aber es steht halt das passwort im Klartext im script!
 
 View user's profile Send private message  
Reply with quote Back to top
garfield168
Post subject:   PostPosted: Sep 06, 2005 - 12:06 PM



Joined: Mar 11, 2004
Posts: 89

Vielen vielen Dank, sehr gut, mit einem Skript wäre es zwar noch besser aber egal. Wie gesagt das Passwort darf im Klartext da stehen. Es kennt sowieso jeder. Man kann sich halt nur nicht als root einloggen.
 
 View user's profile Send private message  
Reply with quote Back to top
Nighthawk
Post subject:   PostPosted: Jul 24, 2006 - 06:24 PM



Joined: Apr 05, 2005
Posts: 39

hallo
was mache ich falsch bei mir kommt immer
su: Muss von einem Terminal gestartet werden
Und ich bin christian

_________________
Sie können ihren Computer jetzt wegschmeissen
 
 View user's profile Send private message  
Reply with quote Back to top
Boregard
Post subject:   PostPosted: Jul 27, 2006 - 09:14 AM



Joined: May 20, 2005
Posts: 323
Location: Niedernberg
Wie hast Du das denn gestarted???
 
 View user's profile Send private message  
Reply with quote Back to top
Nighthawk
Post subject:   PostPosted: Jul 27, 2006 - 01:49 PM



Joined: Apr 05, 2005
Posts: 39

mit testsu.sh in einer Konsole

_________________
Sie können ihren Computer jetzt wegschmeissen
 
 View user's profile Send private message  
Reply with quote Back to top
slh
Post subject:   PostPosted: Jul 27, 2006 - 03:38 PM



Joined: Aug 16, 2004
Posts: 1905

Wäre sudo für den Zweck nicht die bessere Lösung?
 
 View user's profile Send private message  
Reply with quote Back to top
Boregard
Post subject:   PostPosted: Jul 31, 2006 - 07:14 AM



Joined: May 20, 2005
Posts: 323
Location: Niedernberg
Was passiert, wenn Du 'su' in der selben Konsole eingibst??
 
 View user's profile Send private message  
Reply with quote Back to top
Cool J.
Post subject:   PostPosted: Jul 31, 2006 - 03:40 PM



Joined: Jul 13, 2005
Posts: 73

ist das script ausführbar gemacht???
 
 View user's profile Send private message ICQ Number 
Reply with quote Back to top
gsb
Post subject:   PostPosted: Aug 16, 2006 - 09:43 AM



Joined: Sep 23, 2005
Posts: 488

Ich habe für das Mounten eines Lanservers (mount geht nur mit root) folgende Lösung, unter Mithilfe dieses Forums, gefunden.
Ein Script, das dem User gehört, erfragt Passwort und Benutzername (eingabe), einZweites, welches root gehört, mountet (mount_lan). Dieses zweite Script habe ich ist in die Datei /etc/sudoers eingetragen.

#!/bin/bash
#
# eingabe - Benutzernamen und Passwort erfragen

BEN=$(kdialog --caption "Anmeldung" --inputbox "Bitte Benutzernamen eingeben")

PWD=$(kdialog --caption "Passwort" --passwd "Bitte Passwort eingeben")

sudo /home/user/mount_lan $BEN $PWD


#!/bin/bash
#
# mount_lan Lanserver mounten

mount -t cifs -o username=$1,password=$2 //lanserver_name/Benutzer$ /home/user/Lan_Server

Eintrag in /etc/sudoers – kann nur root tun

%users ALL=NOPASSWD:/home/userverzeichnis/mount_lan

Mit diesem Wissen solltest du imstande sein, dein Script anzupassen.

MfG
Josef
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
gsb
Post subject:   PostPosted: Oct 19, 2008 - 09:24 PM



Joined: Sep 23, 2005
Posts: 488

#!/bin/bash
#
# eingabe - Benutzernamen und Passwort erfragen

BEN=$(kdialog --caption "Anmeldung" --inputbox "Bitte Benutzernamen eingeben")

PWD=$(kdialog --caption "Passwort" --passwd "Bitte Passwort eingeben")

sudo /home/user/mount_lan $BEN $PWD

Wenn nun der Benutzer einen Fehler bei der Eingabe macht - wie kann dieses Script automatisch wiederholt werden?

josef
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
 
Deutsch | English
Logos and trademarks are the property of their respective owners, comments are property of their posters, the rest is © 2004 - 2006 by Jörg Schirottke (Kano).
Consult Impressum and Legal Terms for details. Kanotix is Free Software released under the GNU/GPL license.
This CMS is powered by PostNuke, all themes used at this site are released under the GNU/GPL license. designed and hosted by w3you. Our web server is running on Kanotix64-2006.