3

I'm trying to start sshd as user for testing purposes, but it does not work.

sshd_config:

#   $OpenBSD: sshd_config,v 1.84 2011/05/23 03:30:07 djm Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

Port 10022

RSAAuthentication yes
PubkeyAuthentication yes

AuthorizedKeysFile  ./authorized_keys

PasswordAuthentication no

HostKey ./sshkey

UsePrivilegeSeparation no
PidFile ./sshd.pid

jauhien@localhost openssh % /usr/sbin/sshd -f sshd_config -D -ddd

debug2: load_server_config: filename sshd_config
debug2: load_server_config: done config len = 201
debug2: parse_server_config: config sshd_config len 201
debug1: Config token is port
debug3: sshd_config:13 setting Port 10022
debug1: Config token is rsaauthentication
debug3: sshd_config:15 setting RSAAuthentication yes
debug1: Config token is pubkeyauthentication
debug3: sshd_config:16 setting PubkeyAuthentication yes
debug1: Config token is authorizedkeysfile
debug3: sshd_config:18 setting AuthorizedKeysFile ./authorized_keys
debug1: Config token is passwordauthentication
debug3: sshd_config:20 setting PasswordAuthentication no
debug1: Config token is hostkey
debug3: sshd_config:22 setting HostKey ./sshkey
debug1: Config token is useprivilegeseparation
debug3: sshd_config:24 setting UsePrivilegeSeparation no
debug1: Config token is pidfile
debug3: sshd_config:25 setting PidFile ./sshd.pid
debug1: HPN Buffer Size: 87380
debug1: sshd version OpenSSH_6.4, OpenSSL 1.0.1e 11 Feb 2013
debug3: Incorrect RSA1 identifier
debug1: read PEM private key done: type RSA
debug3: Incorrect RSA1 identifier
debug3: Could not load "/home/jauhien/work/openssh/./sshkey" as a RSA1 public key
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]='-f'
debug1: rexec_argv[2]='sshd_config'
debug1: rexec_argv[3]='-D'
debug1: rexec_argv[4]='-ddd'
debug3: oom_adjust_setup
Set /proc/self/oom_score_adj from 0 to -1000
debug2: fd 3 setting O_NONBLOCK
debug1: Bind to port 10022 on 0.0.0.0.
debug1: Server TCP RWIN socket size: 87380
debug1: HPN Buffer Size: 87380
Server listening on 0.0.0.0 port 10022.
debug2: fd 4 setting O_NONBLOCK
debug3: sock_set_v6only: set socket 4 IPV6_V6ONLY
debug1: Bind to port 10022 on ::.
debug1: Server TCP RWIN socket size: 87380
debug1: HPN Buffer Size: 87380
Server listening on :: port 10022.
debug3: fd 5 is not O_NONBLOCK
debug1: Server will not fork when running in debugging mode.
debug3: send_rexec_state: entering fd = 8 config len 201
debug3: ssh_msg_send: type 0
debug3: send_rexec_state: done
debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8

jauhien@localhost openssh % ssh -v -i ./sshkey 127.0.0.1 -p 10022

OpenSSH_6.4, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 53: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 10022.
debug1: Connection established.
debug1: identity file ./sshkey type 1
debug1: identity file ./sshkey-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.4p1-hpn14v2
ssh_exchange_identification: read: Connection reset by peer

What is wrong with my sshd_config? As I have this error on different machines.

I've seen Is it possible to run sshd as a normal user? but I have UsePrivilegeSeparation no in my config, so it is not the case may be.

UPD. The answer is simple: it works only with absolute paths in config. Thanks to MadHatter.

  • Have you tried using absolute paths both to identify the config file, and inside the config file? – MadHatter Nov 19 '13 at 16:25
  • OK, I'm glad to hear it. It'd probably be good to get this question tied off, so it doesn't float around forever. If you could accept my answer below by clicking on the tick outline, that will prevent it from floating around for years to come, as an unanswered question. – MadHatter Nov 19 '13 at 20:13
4

I know for sure that sshd doesn't enjoy running when the binary itself is specified with a relative path (cd /usr/sbin; ./sshd -f ...); it may well be the same with files specified inside the config file. Try replacing the relative paths both to, and inside, the config file, with absolute paths.

Thanks to a3nm for pointing out the error in my original argument.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.