[systemd-devel] A problem with sshd socket from converting inetd Services

Badiu Mircea Gabriel mircea.badiu at windriver.com
Thu Feb 9 08:53:41 PST 2012


Hello,

I followed the steps from here 
http://0pointer.de/blog/projects/inetd.html to set-up ssh server to 
start when an it detect an incoming connection from remote host vis 22 port.

I make the sshd.socket unit :

/[Unit]
Description=SSH Socket for Per-Connection Servers

[Socket]
ListenStream=22
Accept=yes

[Install]
WantedBy=sockets.target/

and the sshd at .service unit :

/[Unit]
Description=SSH Per-Connection Server

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

enabled the sshd.socker unit :

/systemctl enable sshd.socket/

and output the same like in the http://0pointer.de/blog/projects/inetd.html example:
/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/



My problem is the following :

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

/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/

and here the ssh command is hanging up.


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

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


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

/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->128.224.124.181:51810 (ESTABLISHED)
sshd    373 root    3w  IPv4   6940      0t0  TCP 128.224.124.159:ssh->128.224.124.181:51810 (ESTABLISHED)/


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

/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./

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20120209/0d998f2d/attachment.htm>


More information about the systemd-devel mailing list