Autossh bind errors on distributed downloading system

140 views Asked by At

I've set up a distributed system with multiple spring boot downloaders running on digital ocean droplets connecting to a database over an autossh tunnel as follows to connect to mysql database.

autossh -M 20000 -f [email protected] -L 3308:127.0.0.1:3306 -f -C -q -N

I'm getting the following messages in the auth.log which contains some errors including error: bind: Address already in use and error: channel_setup_fwd_listener_tcpip: cannot listen to port: 20000

Nov 29 08:38:40 SERVER sshd[17748]: Accepted publickey for root from xxx.xxx.xxx.xxx port 41078 ssh2: RSA ---------------------------------
Nov 29 08:38:40 SERVER sshd[17748]: pam_unix(sshd:session): session opened for user root by (uid=0)
Nov 29 08:38:40 SERVER systemd-logind[1339]: New session 2529 of user root.
Nov 29 08:38:40 SERVER sshd[17209]: Received disconnect from xxx.xxx.xxx.88 port 47188:11: disconnected by user
Nov 29 08:38:40 SERVER sshd[17209]: Disconnected from xxx.xxx.xxx.88 port 47188
Nov 29 08:38:40 SERVER sshd[17209]: pam_unix(sshd:session): session closed for user root
Nov 29 08:38:40 SERVER sshd[17713]: error: bind: Address already in use
Nov 29 08:38:40 SERVER sshd[17713]: error: channel_setup_fwd_listener_tcpip: cannot listen to port: 20000
Nov 29 08:38:40 SERVER systemd-logind[1339]: Removed session 2511.
Nov 29 08:38:40 SERVER sshd[17770]: Accepted publickey for root from xxx.xxx.xxx.88 port 47212 ssh2: RSA ---------------------------------
Nov 29 08:38:40 SERVER sshd[17770]: pam_unix(sshd:session): session opened for user root by (uid=0)
Nov 29 08:38:40 SERVER systemd-logind[1339]: New session 2530 of user root.
Nov 29 08:38:40 SERVER sshd[17748]: error: bind: Address already in use
Nov 29 08:38:40 SERVER sshd[17748]: error: channel_setup_fwd_listener_tcpip: cannot listen to port: 20000
Nov 29 08:38:40 SERVER sshd[17770]: error: bind: Address already in use
Nov 29 08:38:40 SERVER sshd[17770]: error: channel_setup_fwd_listener_tcpip: cannot listen to port: 20000
Nov 29 08:38:41 SERVER sshd[17270]: Received disconnect from xxx.xxx.xxx.101 port 3xxx16:11: disconnected by user
Nov 29 08:38:41 SERVER sshd[17270]: Disconnected from xxx.xxx.xxx.101 port 310816
Nov 29 08:38:41 SERVER sshd[17270]: pam_unix(sshd:session): session closed for user root
Nov 29 08:38:41 SERVER systemd-logind[1339]: Removed session 2512.
Nov 29 08:38:42 SERVER sshd[17824]: Accepted publickey for root from xxx.xxx.xxx.xxx port 3xxx56 ssh2: RSA ---------------------------------
Nov 29 08:38:42 SERVER sshd[17824]: pam_unix(sshd:session): session opened for user root by (uid=0)
Nov 29 08:38:42 SERVER systemd-logind[1339]: New session 2531 of user root.
Nov 29 08:38:42 SERVER sshd[17824]: error: bind: Address already in use
Nov 29 08:38:42 SERVER sshd[17824]: error: channel_setup_fwd_listener_tcpip: cannot listen to port: 20000
Nov 29 08:38:45 SERVER sshd[17306]: Received disconnect from xxx.xxx.xxx.xxx port 38672:11: disconnected by user
Nov 29 08:38:45 SERVER sshd[17306]: Disconnected from xxx.xxx.xxx.108 port 38672
Nov 29 08:38:45 SERVER sshd[17306]: pam_unix(sshd:session): session closed for user root
Nov 29 08:38:45 SERVER systemd-logind[1339]: Removed session 2513.
Nov 29 08:38:46 SERVER sshd[17860]: Accepted publickey for root from xxx.xxx.xxx.108 port 3xxx02 ssh2: RSA ---------------------------------
Nov 29 08:38:46 SERVER sshd[17860]: pam_unix(sshd:session): session opened for user root by (uid=0)
Nov 29 08:38:46 SERVER systemd-logind[1339]: New session 2532 of user root.
Nov 29 08:38:46 SERVER sshd[17860]: error: bind: Address already in use
Nov 29 08:38:46 SERVER sshd[17860]: error: channel_setup_fwd_listener_tcpip: cannot listen to port: 20000
Nov 29 08:40:01 SERVER CRON[17896]: pam_unix(cron:session): session opened for user root by (uid=0)
Nov 29 08:40:01 SERVER CRON[17896]: pam_unix(cron:session): session closed for user root
Nov 29 08:40:57 SERVER sshd[17347]: Received disconnect from xxx.xxx.42.10 port 37970:11: disconnected by user
Nov 29 08:40:57 SERVER sshd[17347]: Disconnected from xxx.xxx.42.10 port 37970
Nov 29 08:40:57 SERVER sshd[17347]: pam_unix(sshd:session): session closed for user root
Nov 29 08:40:57 SERVER systemd-logind[1339]: Removed session 2515.
Nov 29 08:40:57 SERVER sshd[17900]: Accepted publickey for root from xxx.xxx.xxx.xxx port 38022 ssh2: RSA ---------------------------------
Nov 29 08:40:57 SERVER sshd[17900]: pam_unix(sshd:session): session opened for user root by (uid=0)
Nov 29 08:40:57 SERVER systemd-logind[1339]: New session 2534 of user root.
Nov 29 08:42:01 SERVER CRON[17935]: pam_unix(cron:session): session opened for user root 

Kindly let me know your thoughts on why this problem is occurring.

Regards Conteh

1

There are 1 answers

0
conteh On

I'm finding from the autossh documentation that

-M port[:echo_port]

specifies the base monitoring port to use. Without the echo port, this port and the port immediately above it ( port + 1) should be something nothing else is using. autossh will send test data on the base monitoring port, and receive it back on the port above. For example, if you specify "-M 20000", autossh will set up forwards so that it can send data on port 20000 and receive it back on 20001.

So i've had to add code to increment the -M by 2 for each downloader launched