2

On my network I have a Windows 8 laptop and a Ubuntu Server running 12.10. I can connect to a Ubuntu file share from my Windows 8 laptop with out any issues.

Question: How would I connect & mount a Windows file share from my Ubuntu Server?

This has to be possible seeing I can connect to a Ubuntu Share from Windows 8.

1
  • I did make a directory in /mnt as well as created a new Windows user called smbuser. Added new user to share. Used this: sudo mount -t cifs //"HOSTNAME"/UbuntuTest /mnt/remote -o username=smbuser Error "could not resolve address for host" Used IP instead. Next asked for Password. Put Windows user password in. Error "host is down:
    – Benjamin Jones
    Mar 29, 2013 at 20:29

4 Answers 4

3

Ubuntu and Gnome make it easy to access files on a Windows network share.

Open the Places Menu, then click on Network. You will see a Windows network icon. Double-click to open it. The next window shows all the domains/workgroups found on your network. Inside each domain/workgroup, you will see all the computers on the domain/workgroup with sharing enabled. Double-click on a computer icon to access its shares and files.

If you want to do it from the command line only:

sudo apt-get install samba smbclient

To mount Windows filesystems using SMB, you will also need smbfs. Enter the command:

sudo apt-get install smbfs

Connecting from the command line is similar to an FTP connection.

List public SMB shares with

smbclient -L //server -U user

Connect to a SMB share with

smbclient //server/share -U user

Enter your user password. You can connect directly with

smbclient //server/share -U user%password

but your password will show on the screen (less secure).

Once connected, you will get a prompt that looks like this:

smb: \>

Type "help", without quotes, at the prompt for a list of available commands.

If you want to mount the Windows share, you need

sudo apt-get install smbfs

then something like:

mkdir ~/mnt
sudo mount -t cifs //myserver_ip_address/myshare ~/mnt -o username=samb_user,noexec
4
  • I will try the commands. I do not have GNOME desktop environment on the Ubuntu Server.
    – Benjamin Jones
    Mar 29, 2013 at 20:40
  • For some ODD reason I had assumed that Ubuntu Server already came with a samba client. Might of found my problem.
    – Benjamin Jones
    Mar 29, 2013 at 20:42
  • Thanks Bubba! However When i try to list the shares on my Windows laptop using smbclient -L //192.168.1.72 -U smbuser , I get session request to 192.168.1.72 failed (Called name not present) session request to 192 failed (Called name not present) session request to *SMBSERVER failed (Called name not present) I just created that windows user and added it to the Windows share because the username I'm logged in with right now is connected to a domain. I can ping my Windows Laptop.
    – Benjamin Jones
    Mar 29, 2013 at 20:50
  • you don't appear to have a share name after the ipaddress?
    – Bubba
    Mar 30, 2013 at 1:31
0

The samba service allows linux machines to connect to windows machines.

Here's one of a ton of articles on the subject:

http://www.howtogeek.com/howto/29167/3-easy-ways-to-connect-to-windows-shared-folders-from-linux/

2
  • These resolutions use nautilus which is a gui based tool for Desktop version of Ubuntu not Server version. I do not have x-windows interface such a GNOME on the Ubuntu Server.
    – Benjamin Jones
    Mar 29, 2013 at 20:37
  • smbclient and sbm mounts work on the command line as well. Google is your friend. There are about 100000000000000000 resources. help.ubuntu.com/community/MountWindowsSharesPermanently
    – PaulProgrammer
    Mar 29, 2013 at 20:41
0

I strongly recommend that you use Autofs to mount your Windows shares. This has many advantages over smbclient or adding cifs mounts to your fstab. Autofs is tolerant of reboots, disconnects when idle, reconnects on demand automatically, and is completely transparent at the user level. Give it a shot.

Here's an example setup.

/etc/auto.master

# bunch of comments

/cifs   auto.cifs  --ghost

+auto.master

/etc/auto.cifs

mntpoint   -fstype=cifs,username=winuser,password=winpass,file_mode=0666,dir_mode=0777   ://winpc/share

When you restart the autofs service, you'll have a new directory, /cifs. You don't have to create it. The autofs creates it, or destroys and then creates if already existing. (So don't try to make your autofs root /media in your auto.master file).

Normally, when you ls /cifs, it would appear empty. Navigating to /cifs/mntpoint would trigger the automount and make the missing mount appear. However, the --ghost option makes the mountpoints stay visible, even when not mounted.


Alternatively, you could have this as the contents of /etc/auto.cifs:

*   -fstype=cifs,username=winuser,password=winpass,file_mode=0666,dir_mode=0777   ://winpc/&

This wildcard notation makes every share from winpc automountable by navigating to /cifs/sharename without having to define each share explicitly in auto.cifs. This gives you the flexibility of creating and destroying shares on your Windows machine at will without having to change anything on your Linux box.

It makes the --ghost option useless, though, so ls /cifs would still appear empty when the cifs mounts haven't been triggered. You'd either have to remember the share names or create symlinks with

ln -s /cifs/sharename ~/sharename

or similar.


Notice that in both examples of auto.cifs the file_mode and dir_mode options. Those are the permissions applied to files and folders of cifs-mounted resources. As they are, they grant read+write permission to everyone. If you wish to dial in the security a little, then:

  • create a group called "net" on your workstation: groupadd net

  • add accounts to that group: usermod -a -G net username

  • in auto.cifs add uid=root,gid=net

  • in auto.cifs change file_mode=0660,dir_mode=0770

Also, if you're going to be storing your network share username and password in auto.cifs don't forget to chmod 600 /etc/auto.cifs to prevent non-root from reading it.

0

To mount from Ubuntu 12.10 you need the cifs-utils package.

Then with root permissions:

mount.cifs //hostname/UbuntuTest /mnt/remote -o username=smbuser

You can also mount via fstab (and I recommend using a credentials file containing the username and password):

//hostname/UbuntuTest /mnt/remote cifs credentials=/home/smbuser/credentials 0 0

Of course "smbuser" must be a valid active Windows account.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .