Showing posts with label samba. Show all posts
Showing posts with label samba. Show all posts

Wednesday, December 21, 2022

MX Linux Samba (or maybe not) SSH Is Awesome

01-05-2024 I think I'll jump ship on my default Linux distro. MX is crisp, fast and I liked the idea of not bowing to systemd but systemd is the way Linux is going ao might as well get used to it. Mint is a suitable landing place.

There may be some reason to use a Linux distro other than MX but I can't think of a good one.
OK, hacking but other than that . . .
So, you need to transfer files from and to Windows and Linux . . .
. . . or maybe from Windows to Windows and Windows network just doesn't work?
I'll do anything to keep from plugging in a flash drive 😎

MX makes Samba easy, sort of - with these hints.
sudo mkdir -p /home/share
(I tried mkdir in the user dir but couldn't change permissions)
sudo chmod -R 0777 /home/share
sudo chown -R yourname /home/share
Check Shares    sudo smbstatus --shares

Run MX Samba setup and point to share
sudo service smbd restart
sudo service nmbd restart

I can't always get to Windows network from MX. Yes, it is painful.

When logging on from Windows to Linux 
Try this . . . If Windows rejected credentials
Use your Microsoft email address
User:MicrosoftAccount\me@email.com
Example: you are Bob and your Microsoft email is BobBarker@live.com and your local PC password is 1234
Enter Bob/BobBarker@live.com - 1234
It works even if you are running Windows with local account.
I know - It's crazy

If all else fails or instead of suffering . . .
Linux to Windows
Xlight server on Windows (simply the easiest ftp server)
Filezilla client on MX or any Linux
or . . .
Windows to Linux
"sudo service ssh start" on MX (clear port 22 on firewall) if ssh not installed, do it.
(Doing ssh -V gives result but server needs installation anyway)
WinSCP on Windows
*** SSH may need to be installed even in MX
sudo apt update
sudo apt install openssh-server
sudo service ssh start (as opposed to system d "sudo systemctl start ssh")
No need to enable on MX it starts at reboot (I think). If not see auto start below.
MX manual says:
Start or restart the ssh daemon as root with the command:
/etc/init.d/ssh start
To auto start at boot:
Session and Startup and add /etc/init.d/ssh start
You may need to edit the /etc/ssh/ssh_config
sudo nano /etc/ssh/ssh_config
After config edit . . .
sudo service ssh restart
To check if ssh running
sudo service ssh status
and . . .
Remember to either turn off the Firewall
sudo ufw status

Or allow port 22
sudo ufw allow ssh
or
sudo ufw allow 22/tcp
or
Use the GUI

Or use a python simple server
Or just use . . .
AnyDesk is often an option depending on the Linux distro.

To sum up a quick setup
sudo apt update
sudo apt install openssh-server
sudo service ssh start
sudo ufw allow ssh
sudo nano /etc/ssh/ssh_config
sudo service ssh restart

Bonus:
1. I don't know why first 10, 15, 25 things to do in xyz-linux never mentions it but . . .
sudo apt install fsearch (it's everything search for linux)
2. Need Linux for your Ventoy drive? Make a snapshot ISO after you get MX updated and just the way you like it and drop the ISO on your Ventoy drive.
3. This is turning into an MX tutorial. This video is full of MX setup info.

In Mint
to install ssh sudo apt install openssh-server to check if enabled sudo systemctl is-enabled ssh if disabled do this sudo systemctl enable ssh sudo systemctl start ssh sudo systemctl status ssh firewall sudo ufw allow ssh sudo ufw status verbose !! Be sure to edit sshd_config port 22 & authorization

Friday, September 4, 2020

Samba Trying To Find The Perfect Simple Setup (It Works)

When logging on from Windows to Linux 
Try this . . . If Windows rejects credentials
Use your Microsoft email address
User:MicrosoftAccount\me@email.com
Example: you are Bob and your Microsoft email is BobBarker@live.com and your local PC password is 1234
Enter Bob/BobBarker@live.com - 1234
It works even if you are running Windows with local account.
I know - It's crazy
Permissions to do anything is another subject but at lease you can see stuff.



Let's be honest . . . If you are setting up Samba like this you only want to share a file or two. 
... A better option might be NitroShare but . . . it can be a challenge to install on some distros and it is out of development.
...... Why not use ssh . . . with Putty and WinSCP (both available with Symenu)

But if you just want this dang thing to work . . . Try this:
*Hint for editing smb.conf
... Nano works fine but running Thunar as root (sudo thunar) works better.

Mint installs a Samba folder containing smb.conf but Samba is not installed out of the box.
This differs with the distributions. Manjaro has Samba installed but no smb.conf. MX has Samba installed and a GUI setup.

Install Samba (sudo apt-get install samba)

Existing smb.conf  [global] settings may need no alterations unless you have long netbios name. 
(Some day I want to figure out what are bare bones essentials in [global] )

Maybe this:
[global]
server string = My Server
workgroup = WORKGROUP
security = user
map to guest = Bad User
name resolve order = bcast host

Just add this to bottom of smb.conf

[share]
path = /home/share
#case sensitive, choose any directory
hosts allow = 192.168.1.0/24
hosts deny = 0.0.0.0/0
browseable = yes 
guest ok = yes 
guest only = yes
read only = no

#the following is not necessary. Permissions on the folder overrides the following anyway.
force user = nobody
force create mode = 0777
force directory mode = 0777

(fyi - I think "guest ok = yes" and "chmod -R 0777" the share folder is the key)

sudo systemctl restart smbd
sudo systemctl restart nmbd
sudo service smbd restart
sudo service nmbd restart
(nmbd will broadcast to the Windows network)

testparm to check for errors

sudo mkdir -p /home/share   (matches choice above)

sudo chmod -R 0777 /home/share

sudo chown -R yourname /home/share

Check Shares    sudo smbstatus --shares

Running smb allows access to share by ip address
Running nmb allows netbios to find and show share in Windows file manager
Starting smb and nmb will not make smb/nmb available on reboot
... Use also "sudo systemctl enable smb" - likewise nmb
...

For Manjaro I copied the Mint smb.conf used above and did the same steps.
I think the Mint smb.conf is the default smb.conf file for Samba in most distributions.
In Manjaro Samba is already installed but not the smb.conf so create one.
You can get the Manjaro smb.conf here if needed but it is not the standard one.
Everything worked. 
Drop Dead Simple
Remember Debian & Arch have different syntax - Deb = systemctl start smbd vx Arch = smb
Remember to sudo systemctl enable smb

...

For PopOS nothing has worked yet. I still always get this . . .
- And yes, this is why I hate Samba


Ok - I got it. I had added a  ;comment in a command line but it didn't show a problem in testparm. You can add a ;comment but on its own line.

I am leaving this link for info but found better way
https://www.youtube.com/watch?v=7Q0mnAT1MRg&t=126s

Caveat = Changes keep happening in Operating Systems. What works today may work tomorrow.
Caveat #2 = Windows 10 likes to add this connection to your "Quick Access" file. If your windows folders don't refresh properly just delete 
%AppData%\Microsoft\windows\recent\automaticdestinations
or try doing standard clear . . .



Additional thoughts -
Permissions and Ownership are critical so chown and chmod familiarity is essential and easy after a few rounds and battles.



Saturday, July 4, 2020

Simple Samba Conf File

2020-09-05 See This

What a pain in the butt -
 . . . good old reliable twins work
. . . ssh & WinSCP
Unless you are in Mint, etc where setting up a share is easy.
Not sure if Nautlis Share can be used on the others.

Worked fine in Bohdi but not PopOS
...Suggestion - add to the bottom of existion smb.conf instead of replacing smb.conf totally
smb.conf file
[global]
server role = standalone server
map to guest = Bad User
usershare allow guests = guest
hosts allow = 192.168.0.0/16 (basic security but not needed) (192.168.1.0/16 be specific?)
hosts deny = 0.0.0.0/0 (basic security but not needed)

[testfolder]
comment = test folder
path = /home/george/testfolder
read only = no
guest ok = yes
force user = george (not sure needed)
force group = george (not sure needed)

Be sure Windows has smb1 active in features

Sunday, September 4, 2016

Samba Setup or Python Share


2018-08-14 Edit:
For what it's worth - Use Manjaro and save yourself some headaches.
(The http server only makes files on linux available and does on receive files)
Python file server in VirtualBox
Manjaro has Python 3
Create a Share folder and add a test file.
Within the Share folder open Terminal and enter the following
python -m http.server
This starts the server
Terminal must stay open while the server is running.
To stop the server, enter Cntl-c
Open a second Terminal and find the IP of machine

ip addr
It should look like this.
The IP here is 192.168.1.38 and the default port is 8000
To get this, the machine's network adapter needs to be set as "bridged" instead of NAT
Now on the Windows host and through the browser you can access the Linux Share server through the IP 192.168.1.38:8000
Using a Debian system with Python 2 the command is python -m SimpleHTTPServer
I Debian has Python 3 then python3 -m http:server works

This is primitive but you can get files from the Linux machine and onto the Windows machine without a Samba setup.


On the other hand if you are running Manjaro, Samba setup is simple
XFCE Desktop do this
sudo pacman -S samba gvfs-smb thunar-shares-plugin
Then this
sudo pacman -S manjaro-settings-samba
Networking should now work.
So far I can only access Windows from Manjaro but not see Manjaro from Windows.
But I can move file both ways.

Here is the documentation
https://wiki.manjaro.org/index.php?title=Using_Samba_in_your_File_Manager

Below are some previous notes on Samba
After all the fooling around this works both ways Win - Linux share.
Some of the lines in smb.conf may not be needed. I hope to set up again with default smb.conf altered and see results. I think my problem was stuff before smb.conf and permissions of 0755. I may have omitted sudo on some syntax the requires it. This is drop dead simple.

Install Samba
mkdir /home/george/share
cd /home/george/share
touch testfile
ls
sudo smbpasswd -a george
sudo groupadd smbusers
sudo chown :smbusers /home/george/Share (case sensitive)
sudo usermod -G smbusers george

cd /etc/samba
ls
cp smb.conf smb.conf.orig
sudo nano smb.conf                        
This works both ways win & linux
[global]
server string = Manjaro
workgroup = WORKGROUP
security = user
map to guest = Bad User (not sure this is necessary)
name resolve order = bcast hosts wins

[Share]
        comment = linux share
        force user = george
        browseable = yes
        path = /home/george/Share
        guest ok = yes
        read only = no
        create mask = 0755

sudo systemctl restart smbd.service
sudo systemctl restart nmbd.service

Best Instruction Here
https://www.youtube.com/watch?v=CnYTRFTkhNo

If you want a faster server setup (But Samba is easy enough)
Quick Manjaro share with Windows, phone, tablet
On PC to shareopen a terminal in the folder you wish to share.
python -m http.server
To determine ip type ip addr

On PC wanting access
http://the IP of the sharing computer:8000

Sharing from other systems with your Manjaro computer with Python2
python -m SimpleHTTPServer
python -m http.server 9000 (or 8000 etc.)
Will work as long as terminal open
Stop with
CTRL+c

Creating a permanent file server
pacman -S python2-twisted
twistd web --path . --port 8000
If you are comfortable with using the default port 8080 It will be enough to simply type:
twistd web
To stop this server you can type:
kill `cat twistd.pid`

Instructions here:
https://wiki.manjaro.org/index.php?title=Sharing_files_in_a_Network_-_the_easy_way

Of course none of this works in Mint now. You can't even restart smbd with the old commands. What crazy crap. Trust me. Linux will never remain consistently usable for normal humans.


BitLocker

BitLocker: How to Protect Yourself Even If You Don’t Use It Many Windows users (including me) run local accounts and never intentionally ...