To resolve your cygrunsrv error while installing an sshd_debug service, you also have to change the <service_name> and not only the <service display name> in:
cygrunsrv -I <service_name> -d "<service display name>" -p <service_path>
where
<service_name> is the windows internal service name
<service display name> is the name displayed in services.msc list
OR you have to stop and remove the already defined service sshd first, before trying to define it again using debug parameters.
Note: The commands below have to be entered in a shell with admin privileges. When sshd is run in debug mode with -d, -dd or -ddd, the server will not fork and will only process one connection and then stop.
To define a second sshd_debug service:
To install a second service named sshd_debug:
/usr/bin/cygrunsrv -I sshd_debug -d "CYGWIN sshd_debug" -p /usr/sbin/sshd -a "-D -d -d -d" -y tcpip
Note that a particular <service_name> or <service display name> cannot be defined more than once, otherwise an error will thrown by cygrunsrv.
Before you start your new sshd_debug service, the normal sshd service has to be stopped:
/usr/bin/cygrunsrv -E sshd
Now start the sshd_debug service:
/usr/bin/cygrunsrv -S sshd_debug
To redefine with the existing sshd service_name:
Another example which will make the cygrunsrv command from your question work (using the service name: sshd):
# Stop the service
/usr/bin/cygrunsrv -E sshd
# Remove the service
/usr/bin/cygrunsrv -R sshd
# Install using the same service_name with debug options
/usr/bin/cygrunsrv -I sshd -d "CYGWIN sshd_debug" -p /usr/sbin/sshd -a "-D -d -d -d" -y tcpip
# Start the service
/usr/bin/cygrunsrv -S sshd
To install a service under a specific account
/usr/bin/cygrunsrv -I sshd_debug -d "CYGWIN sshd_debug" -p /usr/sbin/sshd -a "-D -d -d -d" -y tcpip -u "<account_name>" -w "<password>"
Error: get_socket_address: getnameinfo 2 failed
The function get_socket_address throwing the error message is defined in canohost.c:
static char *
get_socket_address(int sock, int remote, int flags)
{
...
switch (addr.ss_family) {
case AF_INET:
case AF_INET6:
/* Get the address in ascii. */
if ((r = getnameinfo((struct sockaddr *)&addr, addrlen, ntop,
sizeof(ntop), NULL, 0, flags)) != 0) {
error("get_socket_address: getnameinfo %d failed: %s",
flags, ssh_gai_strerror(r));
return NULL;
}
return xstrdup(ntop);
...
}
}
It calls a function getnameinfo with flag NI_NUMERICHOST, which should return a string with the human readable IP address of either the (remote) peer_ipaddr or the local_ipaddr. However, the function fails with an unknown EAI_SYSTEM error (A system error occurred).
So this does not help a lot, but it might indicate that the error has to do with DNS name resolution.
To troubleshoot you could check if the name resolution is working:
# netstat: check where sshd listens and if you have any errors
netstat -ano | grep ":22"
netstat -ao | grep ":22"
# reverse dns lookup
nslookup <remote_ip_address>
nslookup <local_ip_address>
# forward dns lookup (using the hostnames returned by the above commands)
nslookup <remote_hostname>
nslookup <local_hostname>
# or for example using dig
# reverse dns lookup
dig -x <remote_ip_address>
dig -x <local_ip_address>
# forward dns lookup (using the hostnames returned by the above commands)
dig <remote_hostname> +search
dig <local_hostname> +search
- The
reverse dns lookup should return the fqdn
- The
forward dns lookup should return the IP address