Skip to content

Commit

Permalink
Bug 2053: Support importing key files that are specified using home ~…
Browse files Browse the repository at this point in the history
… prefix from OpenSSH config file

https://winscp.net/tracker/2053
(cherry picked from commit fe656b8)

Source commit: 3ead5ac8367798c393a64bbefc8f69dc2c4af42d
  • Loading branch information
martinprikryl committed Dec 15, 2021
1 parent 88f20f6 commit e31d69d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion source/core/SessionData.cpp
Expand Up @@ -1680,7 +1680,15 @@ void TSessionData::ImportFromOpenssh(TStrings * Lines)
{
// It's likely there would be forward slashes in OpenSSH config file and our load/save dialogs
// (e.g. when converting keys) work suboptimally when working with forward slashes.
PublicKeyFile = GetNormalizedPath(Value);
UnicodeString Path = GetNormalizedPath(Value);
const UnicodeString HomePathPrefix = L"~";
if (StartsStr(HomePathPrefix, Path + L"\\"))
{
Path =
GetShellFolderPath(CSIDL_PROFILE) +
Path.SubString(HomePathPrefix.Length() + 1, Path.Length() - HomePathPrefix.Length());
}
PublicKeyFile = Path;
}
else if (SameText(Directive, L"KbdInteractiveAuthentication"))
{
Expand Down

0 comments on commit e31d69d

Please sign in to comment.