Nieuws:

Welkom, Gast. Alsjeblieft inloggen of registreren.
Heb je de activerings-mail niet ontvangen?

Auteur Topic: [Opgelost] Andere PATH bij inloggen via SSH  (gelezen 1217 keer)

Offline Johan van Dijk

  • Administrator
    • johanvandijk
[Opgelost] Andere PATH bij inloggen via SSH
« Gepost op: 2009/03/11, 10:46:54 »
Vreemd probleem:
Als ik via SSH inlog op mijn laptop (Intrepid), dan werken veel belangrijke commando's niet meer.
Bijvoorbeeld:
johan@johan-laptop:~$ reboot
Command 'reboot' is available in '/sbin/reboot'
The command could not be located because '/sbin' is not included in the PATH environment variable.
This is most likely caused by the lack of administrative priviledges associated with your user account.
-bash: reboot: command not found

Ga ik kijken naar de verschillen in de PATH variabele, dan kom ik het volgende tegen:
Directe login:
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Via SSH:
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games

Is dit een bug? Of een veiligheidsmaatregel? Of heb ik zelf iets verkeerds geconfigureerd? Ik kan het niet vinden in ieder geval.
« Laatst bewerkt op: 2009/03/11, 11:29:45 door Johan van Dijk »

Re: Andere PATH bij inloggen via SSH
« Reactie #1 Gepost op: 2009/03/11, 11:17:46 »
Kennelijk neemt SSH /etc/environment niet mee. Dat is volgens mij een extra beveiliging en kan opgeheven worden door in je sshd_config UseLogin op yes te zetten.

Offline Johan van Dijk

  • Administrator
    • johanvandijk
Re: Andere PATH bij inloggen via SSH
« Reactie #2 Gepost op: 2009/03/11, 11:29:11 »
UseLogin levert weer problemen op met X11 forwarding volgens de man page, dat gebruik ik af en toe wel.
Maar je hebt me wel op het goede spoor gezet :)

Ik had de configuratie aangepast om alleen logins met een key toe te staan en de rest te verbieden.
Blijkbaar een foutje gemaakt door UsePAM uit te zetten.

UsePAM weer aangezet en sshd opnieuw gestart. Nu werkt het wel weer goed :)

Re: [Opgelost] Andere PATH bij inloggen via SSH
« Reactie #3 Gepost op: 2009/03/11, 11:35:07 »
 :D
Zie UsePAM nu ook staan in mijn sshd_config onder # Allow client to pass locale environment variables

Offline Johan van Dijk

  • Administrator
    • johanvandijk
Re: [Opgelost] Andere PATH bij inloggen via SSH
« Reactie #4 Gepost op: 2009/03/11, 11:40:38 »
Mijn configbestand zegt daar vrij weinig over:
# Package generated configuration file
# See the sshd(8) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

UsePAM yes

Re: [Opgelost] Andere PATH bij inloggen via SSH
« Reactie #5 Gepost op: 2009/03/11, 11:56:42 »
Dat kan wel kloppen, zie nu pas het woordje locale staan en vervolgens de regel AcceptEnv LANG LC_*
Heeft er dus niet zo veel mee te maken, maar zag dat staan en vervolgens vlak eronder UsePAM
Dus ik gelijk een link leggen die er niet echt is...  :rolleyes: