Mount Samba Shares Permanently: Difference between revisions
From WikiMLT
m Text replacement - "mlw-continue" to "code-continue" |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
<noinclude>{{ContentArticleHeader/Linux_Server|toc=off}}{{ContentArticleHeader/Network Security}}</noinclude> | <noinclude>{{ContentArticleHeader/Linux_Server|toc=off}}{{ContentArticleHeader/Network and Security}}</noinclude> | ||
== Prerequisites == | == Prerequisites == | ||
Line 8: | Line 8: | ||
'''1.''' Create a mounting directory.<syntaxhighlight lang="shell" line="1"> | '''1.''' Create a mounting directory.<syntaxhighlight lang="shell" line="1"> | ||
sudo mkdir /home/share-desktop-x | sudo mkdir /home/share-desktop-x | ||
</syntaxhighlight>'''2.''' Add the following line to <code>/etc/fstab</code>.<syntaxhighlight lang="shell" class=" | </syntaxhighlight>'''2.''' Add the following line to <code>/etc/fstab</code>.<syntaxhighlight lang="shell" class="code-continue" line="1"> | ||
sudo nano /etc/fstab | sudo nano /etc/fstab | ||
</syntaxhighlight><syntaxhighlight lang="bash" line="1" start="19"> | </syntaxhighlight><syntaxhighlight lang="bash" line="1" start="19"> | ||
Line 23: | Line 23: | ||
== Mount password protected network folders == | == Mount password protected network folders == | ||
'''A.''' Add the conditionals as plain text in <code>/etc/fstab</code>. This is the quickest and most unsafe approach. | '''A.''' Add the conditionals as plain text in <code>/etc/fstab</code>. This is the quickest and most unsafe approach. | ||
<syntaxhighlight lang="shell" class=" | <syntaxhighlight lang="shell" class="code-continue" line="1"> | ||
sudo nano /etc/fstab | sudo nano /etc/fstab | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="bash" line="1" start="19" class=" | <syntaxhighlight lang="bash" line="1" start="19" class="code-continue"> | ||
//192.168.1.110/share/ /home/share-desktop-x cifs username=<user>,password=<passwd>,uid=1000,iocharset=utf8,nofail 0 0 | //192.168.1.110/share/ /home/share-desktop-x cifs username=<user>,password=<passwd>,uid=1000,iocharset=utf8,nofail 0 0 | ||
</syntaxhighlight><syntaxhighlight lang="shell" line="1"> | </syntaxhighlight><syntaxhighlight lang="shell" line="1"> | ||
Line 32: | Line 32: | ||
</syntaxhighlight>'''B.''' By using <code>~/.smbcredentials</code>. | </syntaxhighlight>'''B.''' By using <code>~/.smbcredentials</code>. | ||
'''B.1.''' Create this file wit content as follow, ad set restrictive permissions. | '''B.1.''' Create this file wit content as follow, ad set restrictive permissions. | ||
<syntaxhighlight lang="shell" class=" | <syntaxhighlight lang="shell" class="code-continue" line="1"> | ||
nano ~/.smbcredentials | nano ~/.smbcredentials | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="bash" class=" | <syntaxhighlight lang="bash" class="code-continue" line="1"> | ||
username=<user> | username=<user> | ||
password=<passwd> | password=<passwd> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="shell" class=" | <syntaxhighlight lang="shell" class="code-continue" line="1"> | ||
chmod 600 ~/.smbcredentials | chmod 600 ~/.smbcredentials | ||
</syntaxhighlight>'''B.2.''' Modify or add the relevant line in the following line to <code>/etc/fstab</code> and remount.<syntaxhighlight lang="shell" class=" | </syntaxhighlight>'''B.2.''' Modify or add the relevant line in the following line to <code>/etc/fstab</code> and remount.<syntaxhighlight lang="shell" class="code-continue" line="1"> | ||
sudo nano /etc/fstab | sudo nano /etc/fstab | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="bash" line="1" start="19" class=" | <syntaxhighlight lang="bash" line="1" start="19" class="code-continue"> | ||
//192.168.1.110/share/ /home/share-desktop-x cifs credentials=/home/<user>/.smbcredentials,uid=1000,iocharset=utf8,nofail 0 0 | //192.168.1.110/share/ /home/share-desktop-x cifs credentials=/home/<user>/.smbcredentials,uid=1000,iocharset=utf8,nofail 0 0 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 56: | Line 56: | ||
{{devStage | {{devStage | ||
| Прндл = Linux Server | | Прндл = Linux Server | ||
| Прндл1 = Network Security | | Прндл1 = Network and Security | ||
| Стадий = 6 | | Стадий = 6 | ||
| Фаза = Утвърждаване | | Фаза = Утвърждаване |
Latest revision as of 07:29, 26 September 2022
Prerequisites
CIFS installation.
sudo apt update && sudo apt install cifs-utils
Mounting unprotected (guest) network folders
1. Create a mounting directory.
sudo mkdir /home/share-desktop-x
2. Add the following line to /etc/fstab
.
sudo nano /etc/fstab
//192.168.1.110/share/ /home/share-desktop-x cifs guest,uid=1000,iocharset=utf8,nofail 0 0
guest
indicates you don't need a password to access the share,uid=1000
makes the Linux user specified by the id the owner of the mounted share, allowing them to rename files,iocharset=utf8
allows access to files with names in non-English languages. This doesn't work with shares of devices like the Buffalo Tera Station, or Windows machines that export their shares usingISO8895-15
,nofail
allows the system to boot properly when the minting device (volume, share) is not avalilable.- If there is any space in the server path, you need to replace it by
\040
, for example//servername/My\040Documents
.
3. Remount the entries listed in /etc/fstab
.
sudo mount -a
Mount password protected network folders
A. Add the conditionals as plain text in /etc/fstab
. This is the quickest and most unsafe approach.
sudo nano /etc/fstab
//192.168.1.110/share/ /home/share-desktop-x cifs username=<user>,password=<passwd>,uid=1000,iocharset=utf8,nofail 0 0
sudo mount -a
B. By using ~/.smbcredentials
.
B.1. Create this file wit content as follow, ad set restrictive permissions.
nano ~/.smbcredentials
username=<user>
password=<passwd>
chmod 600 ~/.smbcredentials
B.2. Modify or add the relevant line in the following line to /etc/fstab
and remount.
sudo nano /etc/fstab
//192.168.1.110/share/ /home/share-desktop-x cifs credentials=/home/<user>/.smbcredentials,uid=1000,iocharset=utf8,nofail 0 0
sudo mount -a
References
- Ubuntu Wiki: Mount Windows Shares Permanently – This is the main source, it contains more explanations, including: a) Special permissions; b) Mount password protected shares using
libpam_mount
; c) Troubleshooting. Here is a local copy of the article.