Bug 426987

Summary: Android app increments port numbers for SFTP plugin, result is many extra known_hosts keys on desktop.
Product: [Applications] kdeconnect Reporter: Tom Brossman <tom>
Component: android-applicationAssignee: Albert Vaca Cintora <albertvaka>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Android   
OS: Android 10.x   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Tom Brossman 2020-09-26 10:37:52 UTC
SUMMARY

If I restart my router, or toggle WiFi off/on on my mobile phone, and the SFTP auto-connect option is enabled, the Android app increments the port number it chooses by one, which causes unwanted extra entries in the ~/.ssh/known_hosts file of the paired desktop Linux machine. If the Android app reused the same port when reconnecting, this would not happen.

STEPS TO REPRODUCE

1. Pair Android app with desktop Linux machine
2. Enable SFTP (and auto-connect) option
3. After pairing is established, observe one new host key for mobile phone in desktop machine's known_hosts file
4. Toggle WiFi off/on and wait a moment for app to reconnect SFTP.
5. (optional) Set HashKnownHosts to 'yes' in desktop SSH config file, to confirm source IP of the redundant lines originates from mobile phone's LAN IP.

OBSERVED RESULT

A new host key appears in the desktop machine's known_hosts file every single time WiFi + SFTP disconnects and reconnects.

EXPECTED RESULT

The same port should be reused so that only one host key ever appears in the desktop machine's known_hosts file after WiFi + SFTP disconnects and reconnects.

SOFTWARE/OS VERSIONS

Android 10
Google Pixel 4
KDE Connect 1.14.2 (From F-Droid)

Ubuntu 20.04.01
GSConnect GNOME Shell extension 

ADDITIONAL INFORMATION

Example sequential host key/port combinations from known_hosts:

[192.168.1.102]:1740 ssh-rsa AAAAB3NzaC1yc...<redacted>
[192.168.1.102]:1741 ssh-rsa AAAAB3NzaC1yc...<redacted>
[192.168.1.102]:1742 ssh-rsa AAAAB3NzaC1yc...<redacted>
[192.168.1.102]:1743 ssh-rsa AAAAB3NzaC1yc...<redacted>