Persistent connection to Windows shared folder using Linux Ubuntu

This is how you can connect to a windows shared folder as persistent using Linux Ubuntu, in this case we will connect to a Windows server using a domain user for connection credentials

At first step we must create a now dir in media location, in ths case we will use testfolder

sudo mkdir /media/testfolder

Then we will prepare a file with credentions we are going to use to do the connection, this user and password must exist in windows ad and need correct right to the shared folder. Of corse we can use a local user if our windows share is not in a domain enviroment.

A good location for this file is our user home folder, in this case we are going to create a hidden one in administrator folder

sudo vi /home/administrator/.cifscredentials

Add our own credentials to this file

#Define user
username=jdoe
#Define password for this user
password=12345678
#Network domain 
domain=MYDOMAIN

Give correct rights to this new created file

sudo chmod 0600 /home/administrator/.cifscredentials

Now it’s time to edit the fstab file and define this connection

sudo vi /etc/fstab

Add the following line

#Windows shared folder connection
//SERVERNAME/SHARED /media/testfolder cifs iocharset=utf8,rw,credentials=/home/administrator/.cifscredentials,uid=1000,dir_mode=0777,gid=1000 0 0

Now its time to test this new share

sudo mount -a

List folder items

ls /media/testfolder

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.