Page 2 of 2
Re: SFTP Deletefile strange behaviour
Posted: Mon Dec 22, 2025 5:43 pm
by Kwai chang caine
I hope you can edit a text file in ubuntu.
Yes i use Filezilla and notepad++
In "ssh_config" there is no line
Subsystem sftp internal-sftp -l VERBOSE
# This is the ssh client system-wide configuration file. See
# ssh_config(5) for more information. This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.
# Configuration data is parsed as follows:
# 1. command line options
# 2. user-specific file
# 3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.
# Site-wide defaults for some commonly used options. For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.
Include /etc/ssh/ssh_config.d/*.conf
Host *
# ForwardAgent no
# ForwardX11 no
# ForwardX11Trusted yes
# PasswordAuthentication yes
# HostbasedAuthentication no
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# GSSAPIKeyExchange no
# GSSAPITrustDNS no
# BatchMode no
# CheckHostIP no
# AddressFamily any
# ConnectTimeout 0
# StrictHostKeyChecking ask
# IdentityFile ~/.ssh/id_rsa
# IdentityFile ~/.ssh/id_dsa
# IdentityFile ~/.ssh/id_ecdsa
# IdentityFile ~/.ssh/id_ed25519
# Port 22
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
# MACs hmac-md5,hmac-sha1,
umac-64@openssh.com
# EscapeChar ~
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
# VisualHostKey no
# ProxyCommand ssh -q -W %h:%p gateway.example.com
# RekeyLimit 1G 1h
# UserKnownHostsFile ~/.ssh/known_hosts.d/%k
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
i have adding it at the end, save the file and restart
I use the two lines for be sure
/etc/init.d/ssh restart
and
systemctl restart ssh.service
And no error

Re: SFTP Deletefile strange behaviour
Posted: Mon Dec 22, 2025 5:56 pm
by infratec
Hm ...
than there should be a file availabel in the include directory:
Include /etc/ssh/ssh_config.d/*.conf
You can look if there are *.conf files available in the directory
/etc/ssh/ssh_config.d
You added the subsystem line in the main config file?
Maybe the sftp program is startet twice now, or it was tried to start it twice.
With
ps ax | grep ftp
you should see if the -l VERBOSE parameter is used or not.
If not you should check the conf files in the above dirctory if one of them includes the sftp line.
Re: SFTP Deletefile strange behaviour
Posted: Mon Dec 22, 2025 6:06 pm
by Kwai chang caine
You can look if there are *.conf files available in the directory
/etc/ssh/ssh_config.d
No it empty
root@ubuntu:~# ps ax | grep ftp
142172 ? Ss 0:00 /usr/lib/openssh/sftp-server
143118 pts/0 S+ 0:00 grep --color=auto ftp
Re: SFTP Deletefile strange behaviour
Posted: Mon Dec 22, 2025 6:19 pm
by infratec
You looked in the wrong file.
Not /etc/ssh/ssh_config
/etc/ssh/sshd_config
Re: SFTP Deletefile strange behaviour
Posted: Mon Dec 22, 2025 6:27 pm
by Kwai chang caine
Excuse me
/etc/ssh/sshd_config.d
50-cloud-init.conf
60-cloudimg-settings.conf
Re: SFTP Deletefile strange behaviour
Posted: Mon Dec 22, 2025 6:41 pm
by infratec
You did not understand what I wrote.
You have to edit the file
/etc/ssh/sshd_config
AND NOT
/etc/ssh/ssh_config
Btw. I installed the same sftp-server on a debian system and I get in the auth log:
2025-12-22T18:34:54.887258+01:00 test sshd[3475780]: Accepted password for infratec from 192.168.0.254 port 15955 ssh2
2025-12-22T18:34:54.890556+01:00 test sshd[3475780]: pam_unix(sshd:session): session opened for user infratec(uid=1000) by (uid=0)
2025-12-22T18:34:54.897544+01:00 test systemd-logind[577]: New session 1861758 of user infratec
2025-12-22T18:34:54.924356+01:00 test sshd[3475780]: pam_env(sshd:session): deprecated reading of user environment enabled
2025-12-22T18:34:55.046969+01:00 test sftp-server[3475787]: session opened for local user infratec from [192.168.0.254]
2025-12-22T18:34:55.069436+01:00 test sftp-server[3475787]: received client version 3
2025-12-22T18:34:55.097914+01:00 test sftp-server[3475787]: realpath "."
2025-12-22T18:34:55.124659+01:00 test sftp-server[3475787]: opendir "/home/infratec/"
2025-12-22T18:34:55.287028+01:00 test sftp-server[3475787]: closedir "/home/infratec/"
2025-12-22T18:34:55.312850+01:00 test sftp-server[3475787]: remove name "test"
2025-12-22T18:34:55.336939+01:00 test sftp-server[3475787]: session closed for local user infratec from [192.168.0.254]
2025-12-22T18:34:55.363163+01:00 test sshd[3475786]: Received disconnect from 192.168.0.254 port 15955:11: Shutdown
2025-12-22T18:34:55.363339+01:00 test sshd[3475786]: Disconnected from user infratec 192.168.0.254 port 15955
2025-12-22T18:34:55.363868+01:00 test sshd[3475780]: pam_unix(sshd:session): session closed for user infratec
2025-12-22T18:34:55.368731+01:00 test systemd-logind[577]: Session 1861758 logged out. Waiting for processes to exit.
2025-12-22T18:34:55.370350+01:00 test systemd-logind[577]: Removed session 1861758.
I hope to see something similar on your server.
Code: Select all
Path$ = "/home/infratec/"
IdSftp = OpenFTP(#PB_Any, "sftp://192.168.0.147", "infratec", "myStrongPassword")
If IdSftp
SetFTPDirectory(IdSftp, Path$)
If Not DeleteFTPFile(IdSftp, "test")
Debug "Error"
EndIf
CloseFTP(IdSftp)
EndIf
Re: SFTP Deletefile strange behaviour
Posted: Mon Dec 22, 2025 8:19 pm
by Kwai chang caine
/etc/ssh/sshd_config wrote:
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
Include /etc/ssh/sshd_config.d/*.conf
# When systemd socket activation is used (the default), the socket
# configuration must be re-generated after changing Port, AddressFamily, or
# ListenAddress.
#
# For changes to take effect, run:
#
# systemctl daemon-reload
# systemctl restart ssh.socket
#
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PubkeyAuthentication yes
# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
KbdInteractiveAuthentication no
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the KbdInteractiveAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via KbdInteractiveAuthentication may bypass
# the setting of "PermitRootLogin prohibit-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and KbdInteractiveAuthentication to 'no'.
UsePAM yes
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
# override default of no subsystems
Subsystem sftp /usr/lib/openssh/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
PermitRootLogin yes
Re: SFTP Deletefile strange behaviour
Posted: Mon Dec 22, 2025 8:26 pm
by infratec
Yes.
And near at the bottom is the sftp line.
You can add
-l VERBOSE
after sftp-server
After this run:
/etc/init.d/ssh restart
Then you can see with
the access of your code.
And maybe an error.
Re: SFTP Deletefile strange behaviour
Posted: Mon Dec 22, 2025 9:03 pm
by Kwai chang caine
Ayaiiiii !!! miracle Kcc have understand
You have right, now i see the log of SFTP

thanks a lot
2025-12-22T19:58:20.188750+00:00 ubuntu sftp-server[1306]: session opened for local user root from [176.191.216.84]
2025-12-22T19:58:20.213357+00:00 ubuntu sftp-server[1306]: received client version 3
2025-12-22T19:58:20.243724+00:00 ubuntu sftp-server[1306]: realpath "."
2025-12-22T19:58:20.273124+00:00 ubuntu sftp-server[1306]: opendir "/"
2025-12-22T19:58:20.334020+00:00 ubuntu sftp-server[1306]: readlink "/lib"
2025-12-22T19:58:20.363359+00:00 ubuntu sftp-server[1306]: readlink "/bin"
2025-12-22T19:58:20.392616+00:00 ubuntu sftp-server[1306]: readlink "/lib64"
2025-12-22T19:58:20.421832+00:00 ubuntu sftp-server[1306]: readlink "/sbin"
2025-12-22T19:58:20.480340+00:00 ubuntu sftp-server[1306]: closedir "/"
2025-12-22T19:58:20.510786+00:00 ubuntu sftp-server[1306]: opendir "/var/"
2025-12-22T19:58:20.564257+00:00 ubuntu sshd[1248]: Failed password for invalid user frappe from 62.60.131.157 port 28246 ssh2
2025-12-22T19:58:20.569149+00:00 ubuntu sftp-server[1306]: readlink "/var/lock"
2025-12-22T19:58:20.598471+00:00 ubuntu sftp-server[1306]: readlink "/var/run"
2025-12-22T19:58:20.656982+00:00 ubuntu sftp-server[1306]: closedir "/var/"
2025-12-22T19:58:20.687568+00:00 ubuntu sftp-server[1306]: opendir "/var/www/"
2025-12-22T19:58:20.777873+00:00 ubuntu sftp-server[1306]: closedir "/var/www/"
2025-12-22T19:58:20.807314+00:00 ubuntu sftp-server[1306]: opendir "/var/www/MyCreations/"
2025-12-22T19:58:20.901677+00:00 ubuntu sftp-server[1306]: closedir "/var/www/MyCreations/"
2025-12-22T19:58:20.932309+00:00 ubuntu sftp-server[1306]: opendir "/var/www/MyCreations/Sites/"
2025-12-22T19:58:21.019868+00:00 ubuntu sftp-server[1306]: closedir "/var/www/MyCreations/Sites/"
2025-12-22T19:58:21.049452+00:00 ubuntu sftp-server[1306]: opendir "/var/www/MyCreations/Sites/Public/"
2025-12-22T19:58:21.139638+00:00 ubuntu sftp-server[1306]: closedir "/var/www/MyCreations/Sites/Public/"
2025-12-22T19:58:21.168692+00:00 ubuntu sftp-server[1306]: opendir "/var/www/MyCreations/Sites/Public/MySite/"
2025-12-22T19:58:21.257895+00:00 ubuntu sftp-server[1306]: closedir "/var/www/MyCreations/Sites/Public/MySite/"
2025-12-22T19:58:21.278070+00:00 ubuntu sshd[1248]: pam_unix(sshd:auth): check pass; user unknown
2025-12-22T19:58:21.286988+00:00 ubuntu sftp-server[1306]: opendir "/var/www/MyCreations/Sites/Public/MySite/Dev/"
2025-12-22T19:58:21.374700+00:00 ubuntu sftp-server[1306]: closedir "/var/www/MyCreations/Sites/Public/MySite/Dev/"
2025-12-22T19:58:21.403850+00:00 ubuntu sftp-server[1306]: opendir "/var/www/MyCreations/Sites/Public/MySite/Dev/Sources/"
2025-12-22T19:58:21.491454+00:00 ubuntu sftp-server[1306]: closedir "/var/www/MyCreations/Sites/Public/MySite/Dev/Sources/"
2025-12-22T19:58:21.520709+00:00 ubuntu sftp-server[1306]: opendir "/var/www/MyCreations/Sites/Public/MySite/Dev/Sources/Php/"
2025-12-22T19:58:21.609752+00:00 ubuntu sftp-server[1306]: closedir "/var/www/MyCreations/Sites/Public/MySite/Dev/Sources/Php/"
2025-12-22T19:58:21.638999+00:00 ubuntu sftp-server[1306]: opendir "/var/www/MyCreations/Sites/Public/MySite/Dev/Sources/Php/"
2025-12-22T19:58:21.726533+00:00 ubuntu sftp-server[1306]: closedir "/var/www/MyCreations/Sites/Public/MySite/Dev/Sources/Php/"
2025-12-22T19:58:21.755838+00:00 ubuntu sftp-server[1306]: remove name "kcc.txt"
2025-12-22T19:58:21.755925+00:00 ubuntu sftp-server[1306]: sent status No such file
2025-12-22T19:58:21.785169+00:00 ubuntu sftp-server[1306]: session closed for local user root from [176.191.216.84]
2025-12-22T19:58:21.815946+00:00 ubuntu sshd[1251]: Received disconnect from 176.191.216.84 port 55365:11: Shutdown
2025-12-22T19:58:21.816648+00:00 ubuntu sshd[1251]: Disconnected from user root 176.191.216.84 port 55365
2025-12-22T19:58:21.816718+00:00 ubuntu sshd[1251]: pam_unix(sshd:session): session closed for user root
2025-12-22T19:58:21.823015+00:00 ubuntu systemd-logind[639]: Session 8 logged out. Waiting for processes to exit.
2025-12-22T19:58:21.824749+00:00 ubuntu systemd-logind[639]: Removed session 8.
2025-12-22T19:58:22.528425+00:00 ubuntu sshd[1307]: Accepted password for root from 176.191.216.84 port 55368 ssh2
2025-12-22T19:58:22.531262+00:00 ubuntu sshd[1307]: pam_unix(sshd:session): session opened for user root(uid=0) by root(uid=0)
2025-12-22T19:58:22.535261+00:00 ubuntu systemd-logind[639]: New session 9 of user root.
2025-12-22T19:58:22.698370+00:00 ubuntu sftp-server[1353]: session opened for local user root from [176.191.216.84]
2025-12-22T19:58:22.723214+00:00 ubuntu sftp-server[1353]: received client version 3
2025-12-22T19:58:22.752203+00:00 ubuntu sftp-server[1353]: realpath "."
2025-12-22T19:58:22.781425+00:00 ubuntu sftp-server[1353]: opendir "/var/www/MyCreations/Sites/Public/MySite/Dev/Sources/Php/"
2025-12-22T19:58:22.869251+00:00 ubuntu sftp-server[1353]: closedir "/var/www/MyCreations/Sites/Public/MySite/Dev/Sources/Php/"
2025-12-22T19:58:22.899749+00:00 ubuntu sftp-server[1353]: remove name "kcc.txt"
2025-12-22T19:58:22.899854+00:00 ubuntu sftp-server[1353]: sent status No such file
2025-12-22T19:58:22.904852+00:00 ubuntu sshd[1248]: Failed password for invalid user frappe from 62.60.131.157 port 28246 ssh2
2025-12-22T19:58:22.928888+00:00 ubuntu sftp-server[1353]: session closed for local user root from [176.191.216.84]
2025-12-22T19:58:22.958091+00:00 ubuntu sshd[1307]: Received disconnect from 176.191.216.84 port 55368:11: Shutdown
2025-12-22T19:58:22.958442+00:00 ubuntu sshd[1307]: Disconnected from user root 176.191.216.84 port 55368
2025-12-22T19:58:22.958674+00:00 ubuntu sshd[1307]: pam_unix(sshd:session): session closed for user root
2025-12-22T19:58:22.962401+00:00 ubuntu systemd-logind[639]: Session 9 logged out. Waiting for processes to exit.
2025-12-22T19:58:22.964926+00:00 ubuntu systemd-logind[639]: Removed session 9.
2025-12-22T19:58:23.659387+00:00 ubuntu sshd[1355]: Accepted password for root from 176.191.216.84 port 55371 ssh2
2025-12-22T19:58:23.661649+00:00 ubuntu sshd[1355]: pam_unix(sshd:session): session opened for user root(uid=0) by root(uid=0)
2025-12-22T19:58:23.666473+00:00 ubuntu systemd-logind[639]: New session 10 of user root.
2025-12-22T19:58:23.832049+00:00 ubuntu sftp-server[1401]: session opened for local user root from [176.191.216.84]
2025-12-22T19:58:23.857967+00:00 ubuntu sftp-server[1401]: received client version 3
2025-12-22T19:58:23.874835+00:00 ubuntu sshd[1248]: pam_unix(sshd:auth): check pass; user unknown
2025-12-22T19:58:23.887189+00:00 ubuntu sftp-server[1401]: realpath "."
2025-12-22T19:58:23.916208+00:00 ubuntu sftp-server[1401]: remove name "/var/www/MyCreations/Sites/Public/MySite/Dev/Sources/Php/kcc.txt"
2025-12-22T19:58:23.946853+00:00 ubuntu sftp-server[1401]: session closed for local user root from [176.191.216.84]
2025-12-22T19:58:23.977455+00:00 ubuntu sshd[1355]: Received disconnect from 176.191.216.84 port 55371:11: Shutdown
2025-12-22T19:58:23.978040+00:00 ubuntu sshd[1355]: Disconnected from user root 176.191.216.84 port 55371
Re: SFTP Deletefile strange behaviour
Posted: Mon Dec 22, 2025 9:47 pm
by infratec
The program is Ok.
But as mentioned you can jump directly to the directory.
2025-12-22T19:58:21.755838+00:00 ubuntu sftp-server[1306]: remove name "kcc.txt"
2025-12-22T19:58:21.755925+00:00 ubuntu sftp-server[1306]: sent status No such file
Please show the output of:
Code: Select all
ls -al /var/www/MyCreations/Sites/Public/MySite/Dev/Sources/Php/
If the file kcc.txt is there, than the rights are not correct and your ftp user is not allowed to delete it.
Re: SFTP Deletefile strange behaviour
Posted: Mon Dec 22, 2025 9:59 pm
by infratec
Ups... the user has the rights, else the delete with full path will fail too.
Also the file needs to be there.
Maybe it's an ubuntu thing.
Try his:
Code: Select all
DeleteFTPFile(IdSftp, "./kcc.txt")
Re: SFTP Deletefile strange behaviour
Posted: Mon Dec 22, 2025 11:43 pm
by infratec
It is really strange.
On my debian system it works.
On this ubuntu system it fails.
Konfiguration is identical.
Than I asked ChatGPT.
After a very long session the only practical solution for sftp is ...
Use always the fullpath for file delete.
In ftp/ftps you need to change the directory before.
Re: SFTP Deletefile strange behaviour
Posted: Tue Dec 23, 2025 7:42 am
by Kwai chang caine
Yes.. It's alsio ChatGPT who give to me this solution

i show to it the pb documentation, and it say the doc is wrong in my case
I think Fred must modify it and adding a line for prevent that the behaviour can be different according to the OS, and if that not works on SFTP give the fullpath
Again thanks for your precious help
Believe you i must write a thread in bug section ?
Re: SFTP Deletefile strange behaviour
Posted: Tue Dec 23, 2025 10:51 am
by infratec
The problem is not PB.
The problem is a long outstanding bug in the OpenSSH sftp server.
They don't respect the lokal path when deleting a file.
The debian maintainers fixed this bug for debian.
Re: SFTP Deletefile strange behaviour
Posted: Tue Dec 23, 2025 10:59 am
by Kwai chang caine
Ahhh ok !!!
But it's when even important, for not lost times and not notice a bug who finally not exist in PB, to warning in the doc this behaviour no?
The proof ...even you the MASTER of the net, were a little surprised by this behavior.

then imagine KCC he aged two years in one week.
A style of that :
Attention, according to your OS, this fonction can need or not a full path
A little bit like FRED prevent that a function not run on MacOs or linux

This avoids looking for a problem where there isn't one...
We already have enough problems looking for where there are.
