<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    Hello,<br>
    <br>
    I followed the steps from here
    <a class="moz-txt-link-freetext" href="http://0pointer.de/blog/projects/inetd.html">http://0pointer.de/blog/projects/inetd.html</a> to set-up ssh server to
    start when an it detect an incoming connection from remote host vis
    22 port.<br>
    <br>
    I make the sshd.socket unit : <br>
    <pre><i>[Unit]
Description=SSH Socket for Per-Connection Servers

[Socket]
ListenStream=22
Accept=yes

[Install]
WantedBy=sockets.target</i>

and the <a class="moz-txt-link-abbreviated" href="mailto:sshd@.service">sshd@.service</a> unit : 

<i>[Unit]
Description=SSH Per-Connection Server

[Service]
ExecStart=-/usr/sbin/sshd -i -d
StandardInput=socket</i>

enabled the sshd.socker unit : 

<i>systemctl enable sshd.socket</i>

and output the same like in the <a class="moz-txt-link-freetext" href="http://0pointer.de/blog/projects/inetd.html">http://0pointer.de/blog/projects/inetd.html</a> example: 
<i>ln -s '/etc/systemd/system/sshd.socket' '/etc/systemd/system/sockets.target.wants/sshd.socket
# systemctl start sshd.socket
# systemctl status sshd.socket
sshd.socket - SSH Socket for Per-Connection Servers
          Loaded: loaded (/etc/systemd/system/sshd.socket; enabled)
          Active: active (listening) since Mon, 26 Sep 2011 20:24:31 +0200; 14s ago
        Accepted: 0; Connected: 0
          CGroup: name=systemd:/system/sshd.socket</i>



My problem is the following :

- when I'm trying to connect from the remote host by the <i>ssh -vvv root@&lt;ip_target_machine&gt;</i>
I got the following output from ssh : 

<i>OpenSSH_5.5p1, OpenSSL 1.0.0a-fips 1 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 128.224.124.159 [128.224.124.159] port 22.
debug1: Connection established.
debug3: Not a RSA1 key file /home/mbadiu/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /home/mbadiu/.ssh/id_rsa type 1
debug1: identity file /home/mbadiu/.ssh/id_rsa-cert type -1
debug1: identity file /home/mbadiu/.ssh/id_dsa type -1
debug1: identity file /home/mbadiu/.ssh/id_dsa-cert type -1</i>

and here the ssh command is hanging up.


And on target with <i>systemd.log_level=debug and systemd.log_target=kmsg </i>enabled I have the following output : 

<i>[  106.994169] &lt;31&gt;systemd[1]: Incoming traffic on sshd.socket
[  107.060984] &lt;31&gt;systemd[1]: Trying to enqueue job <a class="moz-txt-link-abbreviated" href="mailto:sshd@128.224.124.159:22-128.224.124.181:51810.service/start/replace">sshd@128.224.124.159:22-128.224.124.181:51810.service/start/replace</a>
[  107.188360] &lt;31&gt;systemd[1]: Installed new job <a class="moz-txt-link-abbreviated" href="mailto:sshd@128.224.124.159:22-128.224.124.181:51810.service/start">sshd@128.224.124.159:22-128.224.124.181:51810.service/start</a> as 157
[  107.310350] &lt;31&gt;systemd[1]: Enqueued job <a class="moz-txt-link-abbreviated" href="mailto:sshd@128.224.124.159:22-128.224.124.181:51810.service/start">sshd@128.224.124.159:22-128.224.124.181:51810.service/start</a> as 157
[  107.427256] &lt;31&gt;systemd[1]: About to execute: /usr/sbin/sshd -d -i
[  107.503677] &lt;31&gt;systemd[1]: Forked /usr/sbin/sshd as 373
[  107.568625] &lt;31&gt;systemd[1]: <a class="moz-txt-link-abbreviated" href="mailto:sshd@128.224.124.159:22-128.224.124.181:51810.service">sshd@128.224.124.159:22-128.224.124.181:51810.service</a> changed dead -&gt; running
[  107.683831] &lt;31&gt;systemd[1]: Job <a class="moz-txt-link-abbreviated" href="mailto:sshd@128.224.124.159:22-128.224.124.181:51810.service/start">sshd@128.224.124.159:22-128.224.124.181:51810.service/start</a> finished, result=done
[  107.911948] &lt;39&gt;sshd[373]: debug1: sshd version OpenSSH_5.6p1
[  108.000619] &lt;39&gt;sshd[373]: debug1: read PEM private key done: type RSA
[  108.079175] &lt;39&gt;sshd[373]: debug1: private host key: #0 type 1 RSA
[  108.153394] &lt;39&gt;sshd[373]: debug1: read PEM private key done: type DSA
[  108.231531] &lt;39&gt;sshd[373]: debug1: private host key: #1 type 2 DSA
[  108.305615] &lt;87&gt;sshd[373]: debug1: inetd sockets after dupping: 3, 4
[  108.381723] &lt;86&gt;sshd[373]: Connection from UNKNOWN port 65535
[  108.450502] &lt;30&gt;sshd[373]: SSH-2.0-OpenSSH_5.6</i>


The output of the <i>lsof -i :22</i> command shown me that connection is established by socket but it can't log in : 

<i>COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
systemd   1 root   19u  IPv4   5395      0t0  TCP *:ssh (LISTEN)
systemd   1 root   22u  IPv4   6940      0t0  TCP 128.224.124.159:ssh-&gt;128.224.124.181:51810 (ESTABLISHED)
sshd    373 root    3w  IPv4   6940      0t0  TCP 128.224.124.159:ssh-&gt;128.224.124.181:51810 (ESTABLISHED)</i>


When I manually give <i>/usr/sbin/sshd -d</i> on target I have the following output : 

<i>debug1: sshd version OpenSSH_5.6p1
debug1: read PEM private key done: type RSA
debug1: private host key: #0 type 1 RSA
debug1: read PEM private key done: type DSA
debug1: private host key: #1 type 2 DSA
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-d'
Set /proc/self/oom_adj from 0 to -17
debug1: Bind to port 22 on 0.0.0.0.
Bind to port 22 on 0.0.0.0 failed: Address already in use.</i>

which I think that the sshd.socket service is listening also on the 22 port like /usr/sbin/sshd daemon, and the 22 port is occupied.

I am using systemd-35.


Thanks in advance,
Mircea
</pre>
  </body>
</html>