是否有可能以普通用户身份运行sshd?

我打算用我自己的configuration文件在非特权端口(例如2222)上启动第二个sshd实例。

显然, sshd进程不能设置为login,因为除了正在运行sshd守护进程的用户以外的用户显然是不可能的。

但是,有可能有一个工作的sshd守护进程将为当前正在运行的用户? 对于我的用例,这将是很好的。

我尝试用我自己的configuration文件和主机密钥启动sshd实例,并启动sshd进程(没有关于不是根,就像一些命令的投诉),但是当我尝试连接到该端口时, sshd进程死亡。

 $ /usr/sbin/sshd -dD -h .ssh/id_rsa -p 2222 debug1: sshd version OpenSSH_5.6p1 debug1: read PEM private key done: type RSA debug1: private host key: #0 type 1 RSA debug1: setgroups() failed: Operation not permitted debug1: rexec_argv[0]='/usr/sbin/sshd' debug1: rexec_argv[1]='-dD' debug1: rexec_argv[2]='-h' debug1: rexec_argv[3]='.ssh/id_rsa' debug1: rexec_argv[4]='-p' debug1: rexec_argv[5]='2222' debug1: Bind to port 2222 on 0.0.0.0. Server listening on 0.0.0.0 port 2222. debug1: Bind to port 2222 on ::. Server listening on :: port 2222. debug1: fd 6 clearing O_NONBLOCK debug1: Server will not fork when running in debugging mode. debug1: rexec start in 6 out 6 newsock 6 pipe -1 sock 9 debug1: inetd sockets after dupping: 5, 5 Connection from ::1 port 57670 debug1: Client protocol version 2.0; client software version OpenSSH_5.6 debug1: match: OpenSSH_5.6 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.6 debug1: list_hostkey_types: No supported key exchange algorithms debug1: do_cleanup debug1: do_cleanup debug1: audit_event: unhandled event 12 

debug1: setgroups() failed: Operation not permitted行显然伸出,但它不会死,直到它试图接受连接。

经过一番挖掘,我发现了它。

使用sshd -f ~/.ssh/sshd_config /.ssh/sshd_config sshd -f ~/.ssh/sshd_config启动进程,其中/.ssh/sshd_config是您创build的新文件。 在其他选项(例如不同的主机密钥,不同的端口等)中,您需要添加行UsePrivilegeSeparation no 。 这将防止sshd进程尝试执行任何setuidsetgid调用,并允许它作为用户继续运行,并以用户的身份接受连接。

编辑:在搞清楚别人啾啾这个链接到我这确认这是做到这一点的正确方法后的片刻: http : //cygwin.com/ml/cygwin/2008-04/msg00363.html

作为对此线程的更新,版本7.5中的OpenSSH弃用了UsePrivilegeSeparation选项,因此无法禁用特权分离。 看来,作为一个用户运行SSHD现在是不可能的。

请参阅https://www.openssh.com/releasenotes.html