PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Useradd SSH Login nur nach Home erlauben



TekLab
06.02.06, 21:31
Hallo,

gibt es eine Möglichkeit im useradd Befehl anzugeben, dass der User beim
Login mittels SSH aus Home nicht rauskommt in z.B. /home/alle rein darf aber
in /home/user2 nicht? Mit useradd ..... -s /bin/false kann man ihn ja komplett ausperren will ich aber nicht es muss z.B. als root su user1 klappen.

Oder gibt es einen anderen Befehl? kann man den per Befehl automatisch in die /etc/ssh/sshd_conf als DenyUsers eintragen lassen oder muss man dazu die sshd_conf per Hand bearbeiten.

steve-e
06.02.06, 22:21
Suchst du vielleicht chroot?

Hast du dir mal überlegt, dass es aber auch mit normalen Dateirechten möglich sein sollte die Nutzer daran zu hindern in fremden Home-Verzeichnissen zu wühlen.

Tomek
07.02.06, 10:27
Wir hatten erst kürzlich so einen Thread mit einigen Links und Erklärungen:
http://www.linuxforen.de/forums/showthread.php?t=206139

L00NIX
07.02.06, 20:50
Hallo,

gibt es eine Möglichkeit im useradd Befehl anzugeben, dass der User beim
Login mittels SSH aus Home nicht rauskommt in z.B. /home/alle rein darf aber
in /home/user2 nicht?

Gib dem besagten User auf dem Rechner als Login-Shell /bin/rbash


Gruß
L00NIX

Tomek
08.02.06, 07:50
Verschoben ins Forum "Sicherheit".

-hanky-
08.02.06, 10:48
Gib dem besagten User auf dem Rechner als Login-Shell /bin/rbash


Gruß
L00NIX

Dann würde ich ihm aber noch diverse Programme ( konkret u.a. : vi(m) ) sperren, sonst ist der Schutz völlig wirkungslos. Deshalb würde ich auch eine Lösung mit chroot+ssh bevorzugen :)

-hanky-

TekLab
08.02.06, 14:12
Ah ok danke :)

L00NIX
08.02.06, 19:23
Dann würde ich ihm aber noch diverse Programme ( konkret u.a. : vi(m) ) sperren, sonst ist der Schutz völlig wirkungslos. Deshalb würde ich auch eine Lösung mit chroot+ssh bevorzugen :)


Aus der Man-Page der bash:

A restricted shell is used
to set up an environment more controlled than the standard shell. It
behaves identically to bash with the exception that the following are
disallowed or not performed:

o changing directories with cd

o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV

o specifying command names containing /

o specifying a file name containing a / as an argument to the .
builtin command

o Specifying a filename containing a slash as an argument to the
-p option to the hash builtin command

o importing function definitions from the shell environment at
startup

o parsing the value of SHELLOPTS from the shell environment at
startup

o redirecting output using the >, >|, <>, >&, &>, and >> redirec-
tion operators

o using the exec builtin command to replace the shell with another
command

o adding or deleting builtin commands with the -f and -d options
to the enable builtin command

o Using the enable builtin command to enable disabled shell
builtins

o specifying the -p option to the command builtin command

o turning off restricted mode with set +r or set +o restricted.

These restrictions are enforced after any startup files are read.

When a command that is found to be a shell script is executed (see COM-
MAND EXECUTION above), rbash turns off any restrictions in the shell
spawned to execute the script.



Also Klartext:

Es reicht, die Pfadangabe so zu ändern, dass z.B. nur $HOME/bin drin ist und nur die Binaries darin verlinkt sind, die benötigt werden.