Visual studio and Samba

Hello everyone, I am running openhab on a raspberry pi. I came across Visual studio and am trying to get it working. I can view my folders and edit them but can not save them. I get the error “Insufficient permission. Select ‘Retry as Admin’ …”

I did find


and it appears that my Samba may not be installed or installed incorrectly

I went to https://www.openhab.org/docs/installation/linux.html as mentioned above and looked at

sudo vim /etc/samba/smb.conf

When this opens, putty shows a file that starts

Sample configuration file for the Samba suit for Debian GNU/Linux

I can not edit this file/document (and I do not know how to exit with out closing putty). I am guessing this means that Samba is not installed? So then I just run

sudo apt-get install samba samba-common-bin

and copy ans paste what is shown in https://www.openhab.org/docs/installation/linux.html?

I guess I am just worried about blowing up the little bit of work that I have done, which has probably taken me way longer than it should, but hey I am learning!

Move to openHABian. It’s built for Pi users like you and comes with a working samba config.
You can openhab-cli backup/restore your OH config so it does not get lost on migration.

Google how to exit vim or use nano instead. To exit nano use Ctrl X then Y and Enter. BTW if you only want to view the file use “cat” e.g. cat /etc/samba/smb.conf

If you post your smb.conf maybe someone can help or as mentioned by @mstormi use openhabian as it’s much easier. If no openhabian then your faced with learning both OH and linux at the same time. :grimacing:

EDIT:
@muellercandd: sudo chown -R openhab:openhab /var/lib/openhab2 as the system runs under openhab and files uploaded via samba share use openhabian.

So maybe I misspoke and now I am a little more confused. I am using openhabian on pi. At least when I ssh into the pi, that is what the screen says.
I thought visual studio might be a little easier to work with than putty and help smooth out the learning curve.

Visual Studio is easier than the SSH editors, so many times I have had a typo on a rule or item and spend more time trying to figure out why something didn’t work.

However to H102’s point you will need to use vim or nano (or some editor) to fix the Samba share, chances are your share is owned by a different user of the system than what you are connecting with for the share.

If you do a ls -ahl /etc/openhab2 you will get a dump of the directory with the owner and group (openhab or openhabian). You can have Samba connect as that owner so gain write permissions to the files you are looking to edit.

Here is an example from mine for the /etc/openhab2 folder that provides me access to things/items/rules/etc.

[OpenHAB2]
comment = OpenHAB2
path = /etc/openhab2/
writeable = yes
force user = openhab
force group = openhab

You can also copy your current smb.conf file so if you make things worse for yourself you can always delete the broken one, copy the good one back in place and restart the service.

Yes this will be easier but you will need VSCode and the openhab extension package installed and setup as well.

For samba share I have the following in my smb.config file.
Screenshot at 2019-03-02 08-05-19

Hope this helps with samba and if you need help with VSCode setup let us know.

You need to connect using credentials of user openhab and its password - whatever that is.
Before you do so, make sure you add openhab to the samba password database which is not the same as the system passwd file.

command:when ssh into your openhab box:

smbpasswd -a openhab

Then try to connect to share again

Thank you everyone for your quick responses. Some of this is making sense but a lot of it is still foreign to me, so sorry for any questions that may have obvious answers.

First I did realize that I was enter the samba suit incorctly using

sudo vim /etc/samba/smb.conf

instead of

sudo nano vim /etc/samba/smb.conf

I did see that my code (or script, not sure which is the correct term) did not mathc that of H102 so I updated it to match.

I did try ls -ahl /etc/openhab2 as anonymous.one suggested and it show this
image
But I really do not know what it means or what I would do with it.

As tillykeats commented I use

smbpasswd -a openhab

and I get this
image
The fact that I do not see a user name or password makes me wonder if I do not have something set up? Or do I need to nano int this as well and change these?
At that point, VS would look somewhere for this info? How does that get set up?

You may need to use sudo smbpasswd -a openhab

What does that mean? I did copy and paste it in, but iam not sure what to do with it.

I’m sorry to tell but you seem to be lacking basicmost UNIX skills and you mustn’t expect us to teach you these - this not a Linux support forum.
As I already wrote, better move to openHABian. It comes with Samba and more preinstalled so you don’t have to mess with manually installing things.

Its very true. I am new to all of this and probably way behind almost everyone here, but thats why I am here to try and learn.

As you did say, I shoild move to openhabian, and I thought I did mention that I belive I am in openhabian as that is what I login as when I ssh into my pie?

I am not looking for a direct handout. I just dont know where to go to research the answers.

Well yes your pictures show it.
Run sudo openhab-cli reset-ownership first.
Use sudo openhabian-config and change your password(s) from the menu option 34 next, including the Samba one of course. Also run menu option 13 to re-deploy your share.
Reboot and reconnect to the share from your Windows box.
If that still does not work then you’ve probably messed something up and it’s probably best to reinstall your box. It does not make sense to remotely guide a novice through debugging a file server setup.

This may also help with resolving the issue with your Samba share:

The OP ended up solving the issue and posting his resolution, they ended up using ‘force user’ mapping the anonymous user to Linux user. As you can see in your screenshot of the ls -ahl ‘openhab’ is the user who owns the directory structure.

Also have to recommend while you can leave the Samba share open with no authentication, it may be in your interest to create a second share and experiment with adding an auth; while still being able to work on your OH files with VS…but at the end of the day it is your installation. :wink:

Thank you everyone for replies. mstromi, I followed your steps and all well. As you noted and I agreed, my knowledge and experience is not there. So thank you for your to the point solution. If you have a recommendation to get the basics, I would be interested in hearing it. All thanks again.

Get a cheap book on Linux for Beginners.
But that is only part of the equation.

The book will give you an introduction and basic toolkit of commands and understanding, but then you need to learn how the Linux system is configured for the program (OH) and Oh configuration under Linux. This you can get from this forum but the former, you need to get that book.

Note however that there are different variant/versions of Linux such as (BSD, SystemV) which define the architectures, and various implementations called distributions that further muddy the water by adopting different filesystems structures.

I have been using Linux since 1988 (or rather Unix) and still have to learn stuff when something comes along like installing OH on my Raspberry Pi running linux O/S called Openhabian that is based on Raspbian linux that is based on Debian linux that is based on a core Linux designed by the great Mr Linus Torvalds t,hat is based on Unix which is…

You get the idea

Personally I prefer Debian over all other linux distributions, it’s been around long time, but all other distributions have there pros/cons just like debian , so it is always a personal preference. I used to love Gentoo linux but that certainly isnt something youd want to get into as a “fresher” :slight_smile:

As @tillykeats mentioned get a cheap book on Linux. :+1:

Also, here is a decent link for various Linux distributions and commands.
https://www.poftut.com/find-files-folders-directories-linux-command-line/