Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing a Windows Share from Linux Command Line

Paul Gerke
Advisor

Accessing a Windows Share from Linux Command Line

Is there a way to access a file from a share on a windows server from the command line similar to scp? For example, using scp I can do:
scp gerkep@ux31:/tmp/1.pkg 2.pkg

I am then prompted for the password for the gerkep account on ux31 and then the file is copied.

I imagine being able to do:
scp \\\\nt31\\users\\gerkep\\1.pkg 2.pkg

I would then enter a user name and a password with permission to access the share. Is there some way to do this without needing to mount the share first?

Thanks in advance,
Paul
7 REPLIES
Jimmy Vance
HPE Pro

Re: Accessing a Windows Share from Linux Command Line

If your Windows server has OpenSSH server running you could do something with scp.

Take a look at smbclient to copy files without doing a mount





__________________________________________________
No support by private messages. Please ask the forum!      I work for HPE

If you feel this was helpful please click the KUDOS! thumb below!   
Ralph Grothe
Honored Contributor

Re: Accessing a Windows Share from Linux Command Line

If there was an sshd running on the windows server (e.g. openssh from cygwin) that allowed you to connect this should work similarly as with linux servers.
But usually sshd isn't very common on windows servers and almost always requires extra installation and setup.
But providing access like this isn't the intended purpose of a file windows server.
I think (as with a windows client) one would mount the CIFS share of the windows server locally and according to the granted permissions can access files just ro or rw.
Have a look at man mount.cifs
I think the mentioned smbtools were the forerunner user interface tool to deal with windows/samba file server shares when the protocol was still SMB before it went to CIFS and obtained the blessing of the IETF.
Madness, thy name is system administration
Ralph Grothe
Honored Contributor

Re: Accessing a Windows Share from Linux Command Line

Forgot, as for the mentioned necessity to provide ones credentials, the mentioned mount.cifs manpage lists among others the special mount options user=,password=,credentials=

If you installed the cygwin sshd you get a mapping of the notorious windows drive letter paths to something like e.g.

/cygdrive/c/Programs/...

to map

c:\Programs\...


Madness, thy name is system administration
Paul Gerke
Advisor

Re: Accessing a Windows Share from Linux Command Line

Thanks Jimmy and Ralph,
I was hoping for something that didn't require any setup/configuration before running something from the command line, and didn't require the installation of ssh on the windows server, but that doesn't appear to be possible. I will look at the CIFS man page and see if I can figure out a way to do it, but I suspect that CIFS will require something configured in advance.

Thanks again for your responses,
Paul
Jimmy Vance
HPE Pro

Re: Accessing a Windows Share from Linux Command Line

Did you look at "smbclient"? It works similiar to what your trying to accomplish with scp and doesn't require you to mount the windows file system.

It's a tool in the Samba package which is part of most distributions

http://www.samba.org/samba/docs/man/manpages-3/smbclient.1.html




__________________________________________________
No support by private messages. Please ask the forum!      I work for HPE

If you feel this was helpful please click the KUDOS! thumb below!   
Paul Gerke
Advisor

Re: Accessing a Windows Share from Linux Command Line

Thanks Jimmy,
I appreciate you repeating your suggestion to check out smbclient. I can use it like ftp. Not perfect, but doesn't require mounting.
Paul Sperry
Honored Contributor

Re: Accessing a Windows Share from Linux Command Line

Or you could go the other way around
windows to linux with winscp.

http://winscp.net/eng/download.php