How to put the SSH Key in the Session URL?

Advertisement

Netaction
Joined:
Posts:
3
Location:
Berlin

How to put the SSH Key in the Session URL?

There is a function in the menu to generate a nice URL that directly links into a SCP connection. The URL looks like this:
winscp-scp://ssh-user;x-name=MyNiceProject;x-publickeyfile=C%3A%255CUsers%255Cmyname...%255Cputtyformat.ppk@server.com/www/htdocs/
%255C translates to %5C which translates to \. This means, the path is URL encrypted twice. Strange.

The URL opens with WinSCP 6.5.3. WinSCP thinks that the whole string ssh-user;x-name=MyNiceProject;x-publickeyfile=C%3A%255CUsers%255Cmyname...%255Cputtyformat.ppk is the username.

I converted the URL in a format that looks more like an actual URL:
winscp-scp://ssh-user@server.com/www/htdocs/?x-name=MyNiceProject&x-publickeyfile=C%3A%255CUsers%255Cmyname...%255Cputtyformat.ppk
WinSCP can see the correct username now but completely ignores the key file. It asks for a SSH password.

I tried single encrypted path with %5C, I tried C:\\ and C:/ but nothing works. What is the correct format?

Plus: Is there any way not to specify the full path to the key file, as I don't know where exactly others store their key files?

Reply with quote

Advertisement

Netaction
Joined:
Posts:
3
Location:
Berlin

For the archive. I couldn't fix this, the URL that is generated by WinSCP simply doesn't work.

But I set the SSH Key file as the default for new connections. Then an URL like this works:
sftp://ssh-user@server.com/www/htdocs/site.com/
This format has the advantage that it works even if other users have their ssh key files in different paths.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
42,424
Location:
Prague, Czechia

Re: How to put the SSH Key in the Session URL?

Where/how do you use the URL?
When I start WinSCP with the first URL from your post as the first (only) argument of WinSCP:
winscp.exe winscp-scp://ssh-user;x-name=MyNiceProject;x-publickeyfile=C%3A%255CUsers%255Cmyname...%255Cputtyformat.ppk@server.com/www/htdocs/
it correctly looks for the key in the C:\Users\myname...\puttyformat.ppk path:
. 2025-10-09 08:49:50.838 User name: ssh-user (Password: No, Key file: C:\Users\myname...\puttyformat.ppk, Passphrase: No)

Regarding your question about path to keys: Where would WinSCP look for the keys? There's no standard key path.

Reply with quote

Netaction

Interesting. My projects are documented in a wiki. I've added deep links to the WinSCP connection to the respective project pages. I tried opening the URLs using the Chrome browser in Windows 11.

Reply with quote

Advertisement

You can post new topics in this forum