I'm trying to add a LAN-based IoT feature where a device can push data to a server, but the device doesn't support public key, though it does support SFTP user/pass authentication. I cannot seem to get the pass authentication working and while I can't modify the verbosity of the negotiation on the device, I can test from the command line and see that the SFTP negotiation keeps trying key authentication and for the life of me, I can't figure out why.
I relied on Thread logging-in-chroot-directory-for-sftp.52408 and a few other similar discussions to no avail. I'm sure it's something really dumb I'm just overlooking, probably something so basic that even step-by-step guides skip right over it. I'm hoping someone will say "you did remember to...?" and no, I will not have.
Like most configs (I think) I have a
The chroot directory path is long but the path from /is permissioned as follows.
(now that I write out the empty sub-directories, I feel silly for the structure, but that's for a later cleanup)
I am using openssh from ports,
I've tried a few variations in /usr/local/etc/ssh/sshd_config some of which are commented out for reading pleasure, none yielded a successful connect.
Results from command line:
Results with filezilla (less verbose, but same)
why u no use PasswordAuthentication?
I relied on Thread logging-in-chroot-directory-for-sftp.52408 and a few other similar discussions to no avail. I'm sure it's something really dumb I'm just overlooking, probably something so basic that even step-by-step guides skip right over it. I'm hoping someone will say "you did remember to...?" and no, I will not have.
Like most configs (I think) I have a
nologin
user chrooted to an upload directory like so:device:passhash:1004:9419::0:0:Camera SFTP Account:/sftp/chroot/home/device:/usr/sbin/nologin
The chroot directory path is long but the path from /is permissioned as follows.
Code:
drwxr-xr-x 3 root wheel 3B Sep 19 18:44 sftp/
|_
drwxr-xr-x 3 root wheel 3B Sep 19 18:44 chroot/
|_
drwxr-xr-x 3 root wheel 3B Sep 19 18:44 home/
|_
drwxr-xr-x 3 root wheel 10B Sep 19 18:57 device/
|_
drwxr-xr-x 2 device ftp 2B Sep 19 18:55 up/
I am using openssh from ports,
OpenSSH_9.8-hpn14v15 FreeBSD-openssh-portable-9.8.p1_1,1 pat OpenSSH*
I've tried a few variations in /usr/local/etc/ssh/sshd_config some of which are commented out for reading pleasure, none yielded a successful connect.
Code:
# override default of no subsystems
#Subsystem sftp /usr/libexec/sftp-server
#Subsystem sftp internal-sftp -l WARN -f AUTH
Subsystem sftp internal-sftp
# Match User device
Match Group ftp
PubkeyAuthentication no
PasswordAuthentication yes
ChrootDirectory /sftp/chroot/home/%u/up
AllowTCPForwarding no
AllowAgentForwarding no
PermitTunnel no
PermitTTY no
X11Forwarding no
ForceCommand internal-sftp
# ForceCommand internal-sftp -u 002 -f AUTH -l VERBOSE
# ForceCommand internal-sftp -f AUTH -l WARN
Match all
Results from command line:
Code:
$ sftp -v -o PubkeyAuthentication=no device@de.st.ip.adr <<< 'put myCal.ics /'
OpenSSH_8.9p1 Ubuntu-3ubuntu0.10, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /home/local-user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: hostname canonicalisation enabled, will re-parse configuration
debug1: re-parsing configuration
debug1: Reading configuration data /home/local-user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to de.st.ip.adr [de.st.ip.adr] port 22.
debug1: Connection established.
debug1: identity file /home/local-user/.ssh/id_rsa type -1
debug1: identity file /home/local-user/.ssh/id_rsa-cert type -1
debug1: identity file /home/local-user/.ssh/id_ecdsa type 2
debug1: identity file /home/local-user/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/local-user/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/local-user/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/local-user/.ssh/id_ed25519 type -1
debug1: identity file /home/local-user/.ssh/id_ed25519-cert type -1
debug1: identity file /home/local-user/.ssh/id_ed25519_sk type -1
debug1: identity file /home/local-user/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/local-user/.ssh/id_xmss type -1
debug1: identity file /home/local-user/.ssh/id_xmss-cert type -1
debug1: identity file /home/local-user/.ssh/id_dsa type 1
debug1: identity file /home/local-user/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.10
debug1: Remote protocol version 2.0, remote software version OpenSSH_9.8-hpn14v15 FreeBSD-openssh-portable-9.8.p1_1,1
debug1: compat_banner: match: OpenSSH_9.8-hpn14v15 FreeBSD-openssh-portable-9.8.p1_1,1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to de.st.ip.adr:22 as 'device'
debug1: load_hostkeys: fopen /home/local-user/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:6AwbgmoPjxb4o/TY7ZKAQrWj2Swl8B5qsbFm5vra7xs
debug1: load_hostkeys: fopen /home/local-user/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host 'de.st.ip.adr' is known and matches the ED25519 host key.
debug1: Found key in /home/local-user/.ssh/known_hosts:96
debug1: ssh_packet_send2_wrapped: resetting send seqnr 3
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: ssh_packet_read_poll2: resetting read seqnr 3
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: agent returned 3 keys
debug1: Skipping ssh-dss key /home/local-user/.ssh/id_dsa - corresponding algo not in PubkeyAcceptedAlgorithms
debug1: Will attempt key: /home/local-user/.ssh/id_ecdsa ECDSA SHA256:MKyLq9vefo/XiFeBAZU/c6wDYwUMdxgF2BxQWZGXHto agent
debug1: Will attempt key: local-user@$iku-20190921 ED25519 SHA256:AFTySo6fLLKzd4ah/m078XylDw0FIn1xnthvTpbhAyM agent
debug1: Will attempt key: /home/local-user/.ssh/id_rsa
debug1: Will attempt key: /home/local-user/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/local-user/.ssh/id_ed25519
debug1: Will attempt key: /home/local-user/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/local-user/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256>
debug1: kex_input_ext_info: publickey-hostbound@openssh.com=<0>
debug1: kex_input_ext_info: ping@openssh.com (unrecognised)
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
device@de.st.ip.adr: Permission denied (publickey).
Connection closed.
Connection closed
Results with filezilla (less verbose, but same)
Code:
Status: Waiting to retry...
Status: Connecting to de.st.ip.adr...
Response: fzSftp started, protocol_version=11
Command: open "device@de.st.ip.adr" 22
Status: Using username "device".
Error: FATAL ERROR: Remote side sent disconnect message
Error: type 2 (protocol error):
Error: "Too many authentication failures"
Error: Could not connect to server