From owner-freebsd-questions@FreeBSD.ORG Wed Oct 31 13:49:32 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0800516A509 for ; Wed, 31 Oct 2007 13:49:32 +0000 (UTC) (envelope-from oscartheduck@gmail.com) Received: from el-out-1112.google.com (el-out-1112.google.com [209.85.162.178]) by mx1.freebsd.org (Postfix) with ESMTP id 9865613C48D for ; Wed, 31 Oct 2007 13:49:31 +0000 (UTC) (envelope-from oscartheduck@gmail.com) Received: by el-out-1112.google.com with SMTP id s27so22510ele for ; Wed, 31 Oct 2007 06:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=PtEFNJfjcBHg4tFP8sx/N+y9G5XVnvA7MoWgXSkjE44=; b=LHFLlvXuAi2g81WaQJeUrZWP6iSTFgJIv/qf0LIEgOxW6P/cB2fweztOw/yp03Kxi+PrLwwskILfPLJohgz0aq/bxcP2zaClrj5MoNqRJYE7AYpl2wzFCq2D6K9PNiRzYxwe3EojoqTA81oEHPqJdpC9RR4duhYoe2m1wBqdDRM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=T0rFDOKfLKc7wbxPIqjPjQOuaybRYornJQFCRC5ni0L73jEF9FLTr/NGwoBETqXEX4qycspC7gYzHbnWc5OWFWWui71QBUu7v8Xke9CIQY/Ru5L433yS4Ep6YZhRSrqC2/Vw6G6sX3C6+rSLfAjsO4vUe9vYQWlJ0MImxkdM82M= Received: by 10.142.90.8 with SMTP id n8mr2012893wfb.1193838545808; Wed, 31 Oct 2007 06:49:05 -0700 (PDT) Received: by 10.142.180.12 with HTTP; Wed, 31 Oct 2007 06:49:05 -0700 (PDT) Message-ID: Date: Wed, 31 Oct 2007 07:49:05 -0600 From: James To: "Michael Grant" In-Reply-To: <62b856460710310620v588222edj620e8519643881a3@mail.gmail.com> MIME-Version: 1.0 References: <62b856460710310231h3bc517cdl20300179ac6f1a39@mail.gmail.com> <62b856460710310620v588222edj620e8519643881a3@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: FreeBSD Questions Subject: Re: ssh X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Oct 2007 13:49:32 -0000 On 10/31/07, Michael Grant wrote: > > On 10/31/07, James wrote: > > > > > > > > On 10/31/07, Michael Grant 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?