Last active
December 22, 2017 23:57
-
-
Save alexandrinos/93e50dfd9288f832338f to your computer and use it in GitHub Desktop.
Samba - Sharing Files with Win 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get install samba | |
#we need a different username and password for sambaserver | |
#for convenience, the user and passsword could be same as the username we are logged in linux | |
sudo smbpasswd -a <user_name> | |
#optional if the user is not the owner of the folder | |
#if apache and the user has is not owner(usually root) we need to chmod with and chown | |
#sudo chmod 2775 /var/www -R | |
#sudo chown root:<user_name> /var/www | |
sudo chown <user_name> /var/opt/folder | |
#create a folder to be shared | |
mkdir /home/<user_name>/<folder_name> | |
#make a copy of smb.cnf for safety | |
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_orig | |
#edit the samba configuration file | |
sudo nano /etc/samba/smb.conf | |
#edit this line, if windows has other name than WORKGROUP in Network | |
workgroup = My_Workgroup_Name_As_Appear_in_Windows | |
#add these lines--------- | |
[<folder_name>] | |
path = /home/<user_name>/<folder_name> | |
valid users = <user_name> | |
read only = no | |
writeable=yes | |
------------------------- | |
#restart the samba | |
sudo service smbd restart | |
#END OF SHARING PROCEDURE | |
#check if the config file parameters are ok | |
testparm | |
#to access the network share | |
sudo apt-get install smbclient | |
#list shares | |
smbclient -L //<HOST_IP_OR_NAME>/<folder_name> -U <user> | |
#connect to the samba server and use there the command line for different opts, like cd,ls,l; | |
use help for more informations | |
smbclient //<HOST_IP_OR_NAME>/<folder_name> -U <user> | |
#to acces the network from a browser: | |
#Linux | |
smb://<HOST_IP_OR_NAME>/<folder_name>/ | |
#Windows | |
\\<HOST_IP_OR_NAME>\<folder_name>\ | |
#to list the available shares | |
smbclient -L //<ip_or_host_of_the_linux_or_win> | |
#other commands http://www.computerhope.com/unix/smbclien.htm | |
#for convenience mount on Linux what you have shared in Win with: | |
sudo mount -t cifs -o username=<username> //<10.22.72.29>/<shared_folder> </pathtomountdestination> -o rw | |
#Note: Linux permissions has priority over Samba permissions ! | |
#Options for smb.conf file permissions: | |
#1.- if a user has abbility to create/modify | |
read only = Yes/No # | |
#2. -access wihtoue entering a password | |
guest ok | |
#3. -specify if user has write access to the share | |
writeable = Yes | |
#4. a write access list of users or groups | |
write list = rocky tony | |
#5. -read | |
read list | |
#6. - shares only to specific users or groups | |
valid users | |
#7. invalid users or groups- denied access | |
invalid users | |
#Windows note: Check your sharings before making shares with Linux, if security is a concern: | |
In Control Panel -> Network and Sharing -> Advanced sharing options -> Work or Home | |
Turn Network Discovery ON | |
Turn File and Printer Sharing ON | |
Turn Pubilc folder sharing OFF (this can be changed once it's working) | |
Set File Sharing Connections to 40 bits encryption. | |
Turn Password Protected Sharing OFF | |
Enable User Accounts and Passwords for sharing | |
In Folder Options -> View | |
Turn off The Sharing Wizard | |
In Control Panel-> Administrative Tools -> Services | |
Set Computer Browser to Manual | |
Set Homegroup Listener to Manual (Disable if it starts) | |
Set Homegroup Provider to Manual (Disable if it starts) | |
Set SSDP discovery to Automatic. | |
In Control Panel -> Network and Sharing -> Adaptor Settings -> Local area (or Wireless) Connection -> Right Click-> Properties | |
Uncheck Internet Protocal V6. | |
Reboot your computer. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment