Re: ssh



On Wed, Oct 31, 2007 at 03:23:57PM +0100, Michael Grant wrote:
Yeah, I misread your problem. Are you saying that you want to su to root,
but still have some variables set as they were on the account you sued from?
So you have a user named Michael, say, and you su to root, but when you ssh
you want Michael's .ssh to be the effective one?

Well sort of. When I su, $HOME is set to my homedir and $USER set to
mgrant. This is fine. However, ssh (when sued) doesn't read
$HOME/.ssh, it reads /root/.ssh. And it's not defaulting to logging
into the remote machine as $USER, it tries to log in as root. It does
this because it's hardwired in the code more or less as follows (I've
extracted the relevant code from ssh.c):

original_real_uid = getuid();
pw = getpwuid(original_real_uid);
sprintf(buf, "%s/%s", pw->pw_dir, "ssh-config");
read_config_file(buf);
options.user = strdup(pw->pw_name);

Like I said, it seems like a bug to me. Personally I would have done
a getenv("HOME") and getenv("USER") myself instead of depending on the
userid. Probably they had good reason for doing it the way they did
it.

Probably to do with the fact that both $HOME and $USER can be set by the
user to any arbitrary value:

[daniel@torus:~] --->$ echo $USER $HOME
daniel /home/daniel
[daniel@torus:~] --->$ USER=root
[daniel@torus:~] --->$ HOME=/root
[daniel@torus:/home/daniel] --->$ echo $USER $HOME
root /root
[daniel@torus:/home/daniel] --->$ cd
[daniel@torus:~] --->$ pwd
/root

Not so good for security!

Dan

--
Daniel Bye
_
ASCII ribbon campaign ( )
- against HTML, vCards and X
- proprietary attachments in e-mail / \

Attachment: pgpkh1V3lHINv.pgp
Description: PGP signature



Relevant Pages

  • Re: Can login using root password, but not remotely with SSH
    ... PAM authentication error for root from 192.168.XXX.XXX ... Default behaviour in FreeBSD is for SSH to disallow root login. ...
    (freebsd-questions)
  • Re: Reading roots mail when connected remotely
    ... Daniel A. wrote: ... How do I read the mail sent to root, if I can only access my server via SSH? ...
    (freebsd-questions)
  • RE: Linux hacked
    ... Also, what exactly did the history file show, can you paste it into a mail ... > First let me say I'm a security novice. ... > been unsuccessful in getting root back. ... > via ssh but you could su in once logged in as one of three users. ...
    (Security-Basics)
  • Re: Linux hacked
    ... To find out what kernel version you are running, type "uname -a" without ... > been unsuccessful in getting root back. ... > via ssh but you could su in once logged in as one of three users. ...
    (Security-Basics)
  • RE: Linux hacked
    ... hack the box, pull the drive and save it. ... Use the newest versions of Gentoo, Apache, SSH, PHP and Squirl Mail. ... been unsuccessful in getting root back. ... I found a hidden directory /var/tmp/.tmp that has a bunch of directories ...
    (Security-Basics)