Skip to content

libssh2: use non-deprecated libssh2_knownhost_addc()#21866

Closed
vszakats wants to merge 1 commit into
curl:masterfrom
vszakats:ssh2-addc
Closed

libssh2: use non-deprecated libssh2_knownhost_addc()#21866
vszakats wants to merge 1 commit into
curl:masterfrom
vszakats:ssh2-addc

Conversation

@vszakats

@vszakats vszakats commented Jun 5, 2026

Copy link
Copy Markdown
Member

Supported since libssh2 v1.2.5. Replacing libssh2_knownhost_add(),
which was deprecated in that same version.

The new API supports a comment field.

Ref: libssh2/libssh2#1977

Supported since libssh2 v1.2.5. Replacing `libssh2_knownhost_add()`,
which was deprecated in that same version.

The new API supports a comment field.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates curl’s libssh2 SSH known-host handling to use the non-deprecated libssh2_knownhost_addc() API (deprecated replacement for libssh2_knownhost_add()), enabling support for the newer signature that includes a comment field.

Changes:

  • Replace libssh2_knownhost_add() with libssh2_knownhost_addc() when adding an accepted (but mismatching) host key into the in-memory known-hosts list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/vssh/libssh2.c
Comment thread lib/vssh/libssh2.c
NULL, 0,
LIBSSH2_KNOWNHOST_TYPE_PLAIN |
LIBSSH2_KNOWNHOST_KEYENC_RAW |
keybit, NULL);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this also provide the port number for the host name? Otherwise the change does not seem to do anything different?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant this to avoid the deprecation warning after merging the patch over at libssh2.

Port should be added, yes, I was thinking in a separate PR.

Is there a buffer/internal API to pick the host:port string, to avoid reinventing it locally?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this libssh2 API also needs the hostname within [ brackets ], so no there is no existing function that provides exactly this.

@vszakats vszakats closed this in 3c7d136 Jun 5, 2026
@vszakats vszakats deleted the ssh2-addc branch June 5, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants