www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/04/12/05:07:16

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Sat, 12 Apr 2008 11:06:48 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: How do I run sshd as a particular user?
Message-ID: <20080412090648.GC23852@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <D06D8751-81CE-408B-931B-66DA714FE1CC AT von-campe DOT com> <47C4A0DB DOT 6020007 AT cygwin DOT com> <6ADC05D7-7602-4123-81EF-1DE06D26E91F AT von-campe DOT com> <D1627F08-4387-4C0A-94B2-5AFC6C1EA325 AT von-campe DOT com> <006301c890e8$4fa2f070$2708a8c0 AT CAM DOT ARTIMI DOT COM> <FB6643AB-610F-46F7-B019-389E82E687C8 AT von-campe DOT com> <20080402132726 DOT GG4468 AT calimero DOT vinschen DOT de> <69CA7E11-E788-4149-9246-DCDF5063FBB2 AT von-campe DOT com> <FAB87074-2F1D-4F53-835C-271E735A29E9 AT von-campe DOT com> <c2888f8c0804111711u49c2e41ala1137cd3514ca470 AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <c2888f8c0804111711u49c2e41ala1137cd3514ca470@mail.gmail.com>
User-Agent: Mutt/1.5.16 (2007-06-09)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Apr 12 01:11, Robert McKay wrote:
> In order to run sshd as an unprivileged user I had to use a nasty
> hexedit hack on the sshd.exe file to replace the seteuid() call (which
> fails / returns -1 without admin privileges and causes sshd to exit)
> with a call to isalpha() which has (almost) the same function
> prototype, but always returns 0 unless your userid 'is an alphanumeric
> charater' :)

Aaaaargh!

I don't know what you're doing wrong but this is *totally* unnecessary.
You can run sshd as unprivileged user without having to change the
sshd code.  You can do this while another sshd is running on
port 22 under a privileged account.  What the user has to do is to create
her own sshd_config file and own host keys.  If no other sshd is running
on the machine, just chown the host key files in /etc and switch off
privilege separation in /etc/sshd_config.

For kicks I just tried it.  What I did:

  $ uname -a
  CYGWIN_NT-6.0 vmbert2k8 1.5.25(0.156/4/2) 2008-03-06 17:01 i686 Cygwin
  $ id
  uid=1004(hein) gid=513(None) groups=513(None),545(Users)
  $ pwd
  /home/hein
  $ mkdir -p etc var/run
  $ cp /etc/sshd_config etc
  $ vi etc/sshd_config
  [Set `Port 2022']
  [Set `HostKey /home/hein/etc/ssh_host_rsa_key']
  [Set `UsePrivilegeSeparation no']
  [Set `PidFile /home/hein/var/run/sshd.pid']
  [:wq!]
  $ ssh-keygen -t rsa -f /home/hein/etc/ssh_host_rsa_key -N ''
  Generating public/private rsa key pair.
  Your identification has been saved in /home/hein/etc/ssh_host_rsa_key.
  Your public key has been saved in /home/hein/etc/ssh_host_rsa_key.pub.
  The key fingerprint is:
  02:5d:02:5d:e8:2e:c6:b9:4c:d9:93:6c:13:ef:5d:61 hein AT vmbert2k8
  $ /usr/sbin/sshd -f sshd_config -D

Then, from another machine:

  $ uname -a
  Linux calimero 2.6.23.17-LL #1 SMP Tue Mar 25 11:21:47 CET 2008 x86_64 x86_64 x86_64 GNU/Linux
  $ ssh -l hein -p 2022 vmbert2k8
  hein AT vmbert2k8's password: 
  Fanfare!!!
  You are successfully logged in to this server!!!

  hein AT vmbert2k8
  $ 


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019