Mission impossible: sftp client with user/password support on Redhat UBI
Daniel Nashed – 12 December 2025 12:07:23
Redhat UBI isn't really my favorite container image.
It is licence friendly for container images. But that's it with the benefits.
Here is my current challenge. And this really shows that Linux is not always the same.
I am trying to build a SFTP upload with user/password.
There are two easy to use ways. Plus one other way with sshpass.
But none those methods work on UBI.
In short:
- curl is compiled without sftp support
- lftp is not available in UBI
- scp alone does only support sftp with keys not user/password
- sshpass is not available on UBI
I don't want to switch the container default image to a different based image, but UBI isn't really what helps me to provide a solution to use SFTP to upload diagnostic data to HCL support automatically.
Here are two ways that would work with Ubuntu and other base images. But this isn't available on UBI.
curl -u notes:notes -T /etc/hosts sftp://127.0.0.1/home/notes/hosts
lftp -u notes,notes sftp://127.0.0.1 -e "put /etc/hosts; bye"
I really don't want a solution that doesn't work for the standard base image used by HCL and the community project (UBI).
Probably the safest bet will be to write a small sftp client using libssh2 and statically link it on Alpine to make it available independent from the distribution used.
Similar to what I do with nshmailx.
This is less a technical challenge development a solution. It's more a bundling/tool chain issue.
Here is a quick summary created by ChatGTP to show the the challenge.
Probably I could write something in Java like what is included in Traveler. But this would also be an external program, which needs to be deployed.
For Ubuntu as the base image it would work with curl or better lftp out of the box.
Maybe someone has an additional idea.
- Comments [0]