-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot access network drive from ssh session #139
Comments
This is by design. Mapped network drives are associated with a logon session. SSH remote sessions are created with an associated network logon session (these are independent of other logon sessions). |
Got it. But in that case, should there not be a way to map the drive within the ssh session so I can access it? I got an error when I tried to do that, (as shown above). |
You can map drive within sshd sesion if you did login with password as follows: If logged in via public key or the remote share need a different username and password credential, you can do as follows: |
Huh, so it does. That is strange, because I tried it before (with password login) and it didn't work, as I wrote above. |
well, just to make a comment on network drive letters. I personally don't like them, because they had a lot of side effects, which are not always visible immediately.
Since Windows Vista we are able to use Symbolic Links, allowing you to link UNC path based Directories and Files into the local filesystem, without using network drive letters. If you need to use a different credential on the network connect, then you should use the Windows Credential Manager (Control Panel) to store the credentials to this location. If you want to define the credentials in cmd.exe, powershell or ssh - then use cmdkey.exe - it will store it in the Windows Credential Manager. best regards Peter |
You could also try subst on Windows 7 - which can be used on network resources subst e: '\vboxsrv\myshare' However, you may also be running into Windows built-in protections against delegated authority attacks that prevent pure Windows to Windows WMI calls from getting to network resources on the remote end point. |
@altaurog I have met the same problem in windows Server2008 R2. I was login with password method ,when I type 'net use x: \server\folder' , return error msg "System error 67 has occurred.The network name cannot be found." did you have a resolution for this problem ? |
@zhutouxu sorry, no. I believe |
If you run the SSHD server as the same user you logon to the desktop with AND set EnabledLInkedConnections registry key (https://www.youtube.com/watch?v=kYICwkCnUIk) then you should see the same network drives as the interactive logon. |
In my case (on Windows 10) subst displays that path was not found and net use returns error 58. EDIT: For whatever reason I need to specify both username and password. |
@DarwinJS You misspelled This is what you actually want: reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLinkedConnections" /t REG_DWORD /d 0x00000001 /f |
However, in my experience, even when following the advice, the mapped drives are still broken. So I think this is a real bug which should be fixed if IT Admins are going to use this successfully for a whole lot of headless SW install tasks and other common SSH uses. |
That drive mappings remain restricted to a single session is perfectly sane and fine. However, the problem remains that we still can't access SMB network shares via ssh. The real problem here is #996, namely that sshd does not set up the user-process properly in a new terminal-server session to allow it to store credentials, and therefore both CMDKEY and NET USE fail when they try to store a credential needed to access a file share. That has nothing to do with drive letters (which I'd also rather not use for all the reasons given by @Ventusfahrer, in favor of UNC paths). |
I don't quite agree with the design reasoning given by manojampalam.
So, to use the network drive, I have to go to a more insecure method. As mgkuhn commented, the problem of accessing network shares via ssh remains. sshd needs to setup the user process such that this will work. Further our network shares are offered by a filer, so I don't want to setup sftp from somewhere else to get the data. |
@megahall Your solution did not work for me. I RDP'd into the remote windows server (which has D: mapped to another remote server and can be seen in Explorer) and issued the reg add command. The registry entry was added successfully. Then I ssh'd into the same remote windows server and did a cd to /cygdrive, then ls. No "d", only "c". |
@DarwinJS how do you do that? I get an Error 1297 if I set the OpenSSH service to start as myself. |
For those use network drive who struggled with The shell agent simply do two things:
For whom interested in how the agnet shell implemented, the core part(wrote in Golang): func main() {
config, err := newConfig(configFile)
if err != nil {
panic(err)
}
if err := config.mountSamba(); err != nil && err != errDriveNameAlreadyAssigned {
panic(err)
}
args := os.Args[1:]
cmd := exec.Command(config.Shell, args...)
cmd.Stdin = os.Stdin
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
if e, ok := err.(*exec.ExitError); ok {
if e.ExitCode() != -1 {
os.Exit(e.ExitCode())
}
}
panic(err)
}
} Update: |
The very elegant solution that has since emerged, at least for servers in an Active Directory Domain, is GSSAPI authentication and ticket delegation. If you delete your |
Please - allow mode that we can remote in as admin, AND accessing network at least via a account and password method. Cheers, |
The current possible way I found was that run the sshd with a valid domain account (don't use the default Local Account). Have that domain account set as admin on the remote host, and allow that account to access network files. |
I have Windows 7 running in a virtualbox vm on a debian 8 host. I have a vbox 'shared folder' set up, which appears on the windows machine as a network drive (
\\vboxsrv\myshare
) and is mapped in the explore to the E: drive:When I connect to the windows machine by ssh, I can't see the share:
I found mention of this in a cygwin thread, but even if that were relevant, a non-cygwin implementation of the solution there seems less than ideal. It looks like I would wrap the sshd in a .bat file and use nssm or srvany to create a service out of it, but I imagine stopping and starting the service would not work as expected because sshd would be be a child process.
The text was updated successfully, but these errors were encountered: