Mount Samba Shares Permanently: Difference between revisions
From WikiMLT
m Стадий: 6 [Фаза:Утвърждаване, Статус:Утвърден]; Категория:Linux Server |
|||
Line 5: | Line 5: | ||
sudo apt update && sudo apt install cifs-utils | sudo apt update && sudo apt install cifs-utils | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Mounting unprotected (guest) network folders == | == Mounting unprotected (guest) network folders == | ||
'''1.''' Create a mounting directory.<syntaxhighlight lang="shell" line="1"> | '''1.''' Create a mounting directory.<syntaxhighlight lang="shell" line="1"> | ||
Line 14: | Line 13: | ||
//192.168.1.110/share/ /home/share-desktop-x cifs guest,uid=1000,iocharset=utf8,nofail 0 0 | //192.168.1.110/share/ /home/share-desktop-x cifs guest,uid=1000,iocharset=utf8,nofail 0 0 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* <code>guest</code> indicates you don't need a password to access the share, | * <code>guest</code> indicates you don't need a password to access the share, | ||
* <code>uid=1000</code> makes the Linux user specified by the id the owner of the mounted share, allowing them to rename files, | * <code>uid=1000</code> makes the Linux user specified by the id the owner of the mounted share, allowing them to rename files, | ||
Line 20: | Line 18: | ||
* <code>nofail</code> allows the system to boot properly when the minting device (volume, share) is not avalilable. | * <code>nofail</code> 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 <code>\040</code>, for example <code>//servername/My\040Documents</code>. | * If there is any space in the server path, you need to replace it by <code>\040</code>, for example <code>//servername/My\040Documents</code>. | ||
'''3.''' Remount the entries listed in <code>/etc/fstab</code>.<syntaxhighlight lang="shell" line="1"> | '''3.''' Remount the entries listed in <code>/etc/fstab</code>.<syntaxhighlight lang="shell" line="1"> | ||
sudo mount -a | sudo mount -a | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== 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. | ||
Line 35: | Line 31: | ||
sudo mount -a | sudo mount -a | ||
</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="mlw-continue" line="1"> | <syntaxhighlight lang="shell" class="mlw-continue" line="1"> | ||
Line 55: | Line 50: | ||
sudo mount -a | sudo mount -a | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== References == | == References == | ||
* Ubuntu Wiki: [https://wiki.ubuntu.com/MountWindowsSharesPermanently '''Mount Windows Shares Permanently'''] - This is the main source, it contains more explanations, including: a) Special permissions; b) Mount password protected shares using <code>libpam_mount</code>; c) Troubleshooting. Here is a [[:File:UbuntuWiki - MountWindowsSharesPermanently.pdf|local copy of the article]]. | |||
* Ubuntu Wiki: [https://wiki.ubuntu.com/MountWindowsSharesPermanently '''Mount Windows Shares Permanently'''] - This is the main source, it contains more explanations, including: a) Special permissions; b) Mount password protected shares using <code>libpam_mount</code>; c) Troubleshooting. | |||
<noinclude> | <noinclude> | ||
<div id='devStage'> | <div id='devStage'> |
Revision as of 14:03, 5 August 2022
Template:ContentArticleHeader/Network Security
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.