How to add/remove drives to Windows OpenSSH SFTP server?
While some Windows SFTP servers do implement a virtual root folder which lists available drives, Win32-OpenSSH does not. It redirects the root folder /
to /C:/
(or maybe to a system drive).
If you want to visit another drive, you have to manually change a working directory.
In WinSCP GUI, you can do that using "Open Directory" command and typing a path to the desired drive, like
/D:/
.-
In command-line SFTP clients, like OpenSSH
sftp
, PuTTYpsftp
or WinSCP scripting, you can usecd
command, like:cd /D:/
There's actually WinSCP FAQ for How do I change drive on the remote panel?
Regarding your attempt to solve this using a symlink: A symlink really shows as a file in WinSCP (as the server presents it as an unknown file type). But a directory junction shows as a directory (the server presents it as a regular directory, not a link). Though since WinSCP 5.14.2, you can make WinSCP try to enter "file" using Ctrl+PgDn.
Related videos on Youtube
Mike
Updated on September 18, 2022Comments
-
Mike over 1 year
I've setup the built-in OpenSSH in Windows 10 and connected remotely via WinSCP SFTP protocol. I seem to have access to all folders in my
C:
drive, but I cannot access the external drives of my computer. Going to the "root" folder just lists theC:
drive. I tried creating a soft directory symlinks in a directory that I can access, but that doesn't seem to work. They appear as files in WinSCP and I cannot access them. How can I add them? Also, is there a way to restrict access to certain folders if I wanted to share access to only certain folders of my server? -
Erik almost 5 yearsI have tried to create such a junction using the mklink command in Windows, like this: mklink /D C:\D D:\. However, when I do so, I cannot copy any files to subfolders in /D, it says "access denied" in WinSCP, although when I map the D-rive directly as ChrootDirectory, this works. So by linking, I lose some file permissions, can I set them directly anyhow?
-
Martin Prikryl almost 5 years
/D
does not create a junction. It creates a folder symbolic link. Junction is created by/J
. Though I actually cannot reproduce the problem with symlink (I have described in my answer) anymore. For me even symbolic link works. Maybe they have fixed it meanwhile. Anyway, try/J
. -
Erik almost 5 yearsIt looks like this doesn't work as well for me, it also says in the permissions rwx------. And another thing I noticed is that it tries to create the file as myfile.txt..filepart, which works, so I have that file with size 0, so maybe some renaming process fails? Looks really strange to me, all I can say that the behaviour is similar in WinSCP as in Filezilla, so I guess I need to set some permissions on serverside, but where is the right place to look?
-
Martin Prikryl almost 5 yearsWindows OpenSSH server follows permissions of your Windows account. There's nothing to be set specifically for the SFTP/SSH server. The permissions you see in WinSCP are not really relevant. There's no way the server can map complex Windows ACL to simple *nix-style permissions that you see in WinSCP. -- If you login with an SSH terminal client, can you create files on the junction/symlink?
-
Erik almost 5 yearsMartin, thanks for your reply, it works when I copy the files using putty and an open SSH-connection. Also see my other comment how to reproduce the steps using Filezilla (WinSCP will behave like FIlezilla there)
-
zx485 almost 4 yearsHow does changing the default shell enable adding/removing drives to the OpenSSH SFTP server. I don't get it.