sshfs-win icon indicating copy to clipboard operation
sshfs-win copied to clipboard

UNC syntax to specify key?

Open Noexpert opened this issue 2 years ago • 3 comments

I'm able to connect by mapping a network drive using UNC syntax. I'm also able to connect using SSHF-Win Manager using a custom key location with the -oIdentityFile= flag.

How can I use a custom key with UNC?

Looking at the UNC syntax, I don't see an option to specify a key: \\sshfs.kr\[LOCUSER=]REMUSER@HOST[!PORT][\PATH]

I'm aware of https://github.com/winfsp/sshfs-win/issues/231, but that seems to be for svc

Also related: https://github.com/winfsp/sshfs-win/issues/320 https://github.com/winfsp/sshfs-win/issues/323

Noexpert avatar Mar 19 '22 11:03 Noexpert

Since I spend 2 days figuring it out ;), I will leave it here for future users:

A specific ssh private key can be specified by defining a new alias in the ssh config (file "C:\Users<user name>.ssh\config", containing something like the following:

Host <alias>
    Hostname <actual name of HOST>
    User <remoteServer user name(REMUSER)>
    IdentityFile <path to private key>
    IdentitiesOnly yes

BEWARE: sshfs-win can only use private keys WITHOUT passphrase, since the query for a passphrase can not be passed on to the user. BEWARE: sshfs-win does not use the built in openSSH client of windows, therefore stuff like Proxycommand is not used, only basics as far as I can tell.

BrianMarre avatar Jun 08 '22 12:06 BrianMarre

Thanks for your post.

Do you know how to use that config file with UNC syntax? \\sshfs.kr\[LOCUSER=]REMUSER@HOST[!PORT][\PATH]

Thanks

Noexpert avatar Jun 18 '22 17:06 Noexpert

Yes, you replace HOST with the new name you gave your remote server in the config file.

For example, if the following is the entry in your config file and your private key file is "C:\Users\userLocal.ssh\remoteServerKey"

Host remoteServer
    Hostname remoteServer.example.com
    User user1
    IdentityFile C:\Users\userLocal\.ssh\remoteServerKey
    IdentitiesOnly yes

Then you would specify that as "\sshfs.k\user1@remoteServer", port and remote path can be added as usual.

BrianMarre avatar Jun 19 '22 13:06 BrianMarre

Thanks.

I saved the config file here: C:\Users\User\.ssh\config

Host user1_server
    Hostname hostname.domain.com
    User user1
    IdentityFile C:\Users\User\.ssh\user1
    IdentitiesOnly yes

I then attempt to map a new network drive in Windows Explorer: \\sshfs.kr\user1@user1_server!XXXX\path\, but it fails. Am I using wrong syntax somewhere?

Noexpert avatar Sep 24 '22 23:09 Noexpert

The solution is here: https://github.com/winfsp/sshfs-win/issues/155#issuecomment-1316261288

Noexpert avatar Jan 13 '24 20:01 Noexpert