Access to Network Drive under ssh

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Jun 30 09:40:00 GMT 2006


On Jun 29 22:46, Richard Foulk wrote:
> I've written my own mount command for Cygwin in Perl.  One thing to
> be aware of is that drive letters aren't necessary with Cygwin.
> 
> You can't say: `cd \\xyz\c$' with Windows cmd.exe.
> 
> You *can* say things like: `cd //xyz/c\$' in Cygwin.  This cleans up
> many things.  If you have the right permissions `net use' isn't necessary!
> 
> A wrapper for `net use' in Perl is pretty easy to do, including all
> the password stuff.
> 
> Those drive letters just get in the way.  Don't use them.

To add another data point:

When running under a public key ssh session, you're running in the login
session of the SYSTEM user.  Also, since you used pubkey instead of
password login, you don't have the credentials for network access.  This
has two results:

- You must use the net command to connect to non-public shares.
- You must use username and password in the net use command.
- You can't use drive letters.

So, what you have to do is this:  Use the 'net use' command with full
qualified domain/user name and password, omitting the drive letter, FROM
INSIDE YOUR PUBKEY SSH SESSION.  This is essential.  You only have to do
this once, in your first ssh session, the connection to the shares is
persistent across multiple sessions as long as you don't reboot.

  $ net use \\\\server\\share /user:DOMAIN\\username password
 
If you don't have a domain, use the name of your local windows box
instead.  However, YMMV depending on the security level used on the
server you're connecting to.

Now you can cd to the share as outlined above:

  $ cd //server/share

In my local environment, I have a tiny script to connect to the servers.
I start it manually after a (re)boot FROM INSIDE MY PUBKEY SSH SESSION.
Additionally I have the matching mount points always defined to access
the shares like local directories:

$ cat ~/bin/calimero
#!/bin/bash
SERVER='\\calimero'
SHARES='cygwinsrc cygwinbin'
USER='CATHI\corinna'

pwd=$1
[ -z "$pwd" ] && read -sp "Password: " pwd && echo
[ -z "$pwd" ] && exit 1
for i in $SHARES
do
  net use "$SERVER\\$i" /user:"$USER" $pwd
done
$ mount | grep calimero
\\calimero\cygwinbin on /home/corinna/bin/cygwin type system (binmode)
\\calimero\cygwinsrc on /home/corinna/src/cygwin type system (binmode)

This way I can just manually reconnect to the server after booting
and then use the shares like local dirs:

$ cd ~/src/cygwin/src/winsup
$ df .
Filesystem           1K-blocks      Used Available Use% Mounted on
\\calimero\cygwinsrc  66168952  38452912  27716040  59% /home/corinna/src/cygwin


Corinna


-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list