Re: ssh



On 10/31/07, Michael Grant <mg-fbsd3@xxxxxxxxx> wrote:

On 10/31/07, James <oscartheduck@xxxxxxxxx> wrote:


On 10/31/07, Michael Grant <mg-fbsd3@xxxxxxxxx> wrote:
On 10/31/07, James <oscartheduck@xxxxxxxxx> wrote:



On 10/31/07, Michael Grant <mg-fbsd3@xxxxxxxxx > wrote:

If I'm sued as root and I ssh somewhere, ssh/scp reads it's files
from
/root/.ssh/. The docs say it reads from ~/.ssh which is what I
want,
but it's not doing that. When sued, the shell is properly
expanding ~
to my home dir.

Anyone know of a way around this behavior?

Michael Grant


su - root

Nope. One other suggestion was 'su -l root'. This does not change
the situation either.

I went into the source for ssh and it does a getuid() and then gets
the homedir of that uid. So no amount of fooling with su is gonig to
fix this. I guess it's like this for security reasons, it sure seems
like a bug to me. I'd have used the HOME enviroment variable.

So far, the best fix I've found is to create some aliases in bash as
follows:

alias scp="scp -o User=username -i ~/.ssh/id_rsa"
alias ssh="ssh -l username -i ~/.ssh/id_rsa"
alias rsync="rsync -op -e 'ssh -l username -i
/home/username/.ssh/id_rsa'"




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.

So I think the problem is unsolvable using options to su. Only
solution I found so far was the aliases above.

Michael Grant


You could just pop your code in there and compile it as you want it. Maybe
submit it back to openssh as a bugfix.
_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • 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: X11Forwarding, ssh -X, and /bin/su
    ... ]>but I'm not really tunneled using ssh then, ... ]connecting to the X server and have the home directory NFS-mounted ... ](unless you leave root unmapped over NFS, ... ]root-readable place and set the environment $XAUTHORITY variable ...
    (comp.security.ssh)
  • 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)
  • RE: Linux hacked
    ... Was any of the sites running a php nuke or another portal or system that is vuln ... been able to use that with a locla root exploit to gain root on the machine. ... > hack the box, pull the drive and save it. ... > Use the newest versions of Gentoo, Apache, SSH, PHP and Squirl Mail. ...
    (Security-Basics)