How to set up visual studio with openhab extension with samba?

Hi,
i wanted to edit my files comfortably with the visual studio and the openhab extension. I am running windows 10 on my client machine and on the server side I run openhabian (raspberry3). So now I need to know how to do that?

Is the usual way for this Samba?

Can I also edit the files with visual studio if I am not in the same network (e.g. accessing and editing my files remotely over the internet)?

How do I use Samba? Do I need to search for openhabian in the windows network section and then mount a windows drive with the config files and then access this drive and the files with visual studio?

Yes. That’s how i do it.

But be aware, the openHAB extension is for Visual Studio Code, not Visual Studio.

1 Like

yes visual studio code :wink:

Ok. Openhabian should have preconfigured the samba shares yes?

Unfortunately in my windows network there isn’t shown my openhabian server with its shares. I also tried to set up a network device by entering the ip adress of openhabian and assigning it to a windows drive letter, but it is unable to find and to connect anything.

But I am able to access the normal browser guis by entering the ip and the port 8080.

So what is wrong, where are the shares?

oh and please tell me, will the samba only work when I am in the same network?

I need to sleep now, it is getting too late. Tomorrow I will try more :smiley:

I have defined the Samba password using this on the RPi:

sudo smbpasswd -a openhab

Then this is what I run at Windows startup:

net use O: \\openhabianpi.local\openHAB-conf /user:openhab yourpasswd /persistent:No
net use S: \\openhabianpi.local\openHAB-share /user:openhab yourpasswd /persistent:No

If you have a problem with domain resolution on your local network, you can replace openhabianpi.local with the IP of the server.

1 Like

You need to set the username and password. (Otherwise your windows user is used, which usually has no access to openhabian shares.)

I use the user openhabian, if i recall correctly this user is predefined for the smb shares. Or you can add the user openhab like @Flavio_Costa did.

Or use https://www.sftpnetdrive.com/
as ssh is hopefully allready configured on you pi, just install sftpnet on windows.
Configure you IP, User and password and you are good to go.

1 Like

Thanks man. That solved my problem. With these commands it connects and creates a networkdrive which is also shown in explorer.

Do you also remotely access the files somehow? E.g. when not in the same network?

No, i never did.

But should be register an DynDNS a a free hoster, install and setup ddclient , and configure your Router to forward the ports to you pi.

1 Like

According to some openHAB documentation, the recommended way of accessing the files outside of the network might require a VPN.

Port forwarding may also work, but it is more prone to security vulnerabilities, so a proper VPN tunnel - while not trivial to setup - tends to be the ideal solution.

1 Like

Hello,

If I need to make remote access to samba through internet. which port I have to forward?

Continuing the discussion from How to set up visual studio with openhab extension with samba?:

Hello, https://www.sftpnetdrive.com/ works fine and it could be enough but my question is why this is working but Windows File Explorer not?

I’m using same parameters in both ways.
Could it be a Domain issue?
My sudo pdbedit -L -v output is:

Unix username:        openhabian
NT username:
Account Flags:        [U          ]
User SID:             S-1-5-21-2995739138-2745212930-530578818-1000
Primary Group SID:    S-1-5-21-2995739138-2745212930-530578818-513
Full Name:
Home Directory:       \\openhabianpi\openhabian
HomeDir Drive:
Logon Script:
Profile Path:         \\openhabianpi\openhabian\profile
Domain:               OPENHABIANPI
Account desc:
Workstations:
Munged dial:
Logon time:           0
Logoff time:          never
Kickoff time:         never
Password last set:    Sat, 04 May 2019 02:40:02 CEST
Password can change:  Sat, 04 May 2019 02:40:02 CEST
Password must change: never
Last bad password   : 0 
Bad password count  : 0
Logon hours         : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

My /etc/init.d/samba status output is:


● nmbd.service - Samba NMB Daemon
   Loaded: loaded (/lib/systemd/system/nmbd.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-05-01 14:19:57 CEST; 2 days ago
     Docs: man:nmbd(8)
           man:samba(7)
           man:smb.conf(5)
 Main PID: 574 (nmbd)
   Status: "nmbd: ready to serve connections..."
   CGroup: /system.slice/nmbd.service
           └─574 /usr/sbin/nmbd

May 01 14:19:48 openHABianPi systemd[1]: Starting Samba NMB Daemon...
May 01 14:19:52 openHABianPi systemd[1]: nmbd.service: Supervising process 574 which is not our child. We'll most like…t exits.
May 01 14:19:57 openHABianPi systemd[1]: Started Samba NMB Daemon.
Hint: Some lines were ellipsized, use -l to show in full.
● smbd.service - Samba SMB Daemon
   Loaded: loaded (/lib/systemd/system/smbd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-05-04 02:06:31 CEST; 1h 14min ago
     Docs: man:smbd(8)
           man:samba(7)
           man:smb.conf(5)
 Main PID: 21175 (smbd)
   Status: "smbd: ready to serve connections..."
   CGroup: /system.slice/smbd.service
           ├─21175 /usr/sbin/smbd
           ├─21176 /usr/sbin/smbd
           ├─21177 /usr/sbin/smbd
           └─21179 /usr/sbin/smbd

May 04 02:31:30 openHABianPi smbd[22371]: pam_unix(samba:session): session closed for user nobody
May 04 02:31:41 openHABianPi smbd[22381]: pam_unix(samba:session): session closed for user nobody
May 04 02:32:51 openHABianPi smbd[22404]: pam_unix(samba:session): session closed for user nobody
May 04 02:36:38 openHABianPi smbd[22476]: pam_unix(samba:session): session closed for user nobody
May 04 02:47:36 openHABianPi smbd[22664]: pam_unix(samba:session): session closed for user nobody
May 04 02:51:35 openHABianPi smbd[22714]: pam_unix(samba:session): session closed for user nobody
May 04 02:53:16 openHABianPi smbd[22751]: pam_unix(samba:session): session closed for user nobody
May 04 02:53:53 openHABianPi smbd[22760]: pam_unix(samba:session): session closed for user nobody
May 04 02:54:08 openHABianPi smbd[22767]: pam_unix(samba:session): session closed for user nobody
May 04 02:59:42 openHABianPi smbd[22918]: pam_unix(samba:session): session closed for user nobody

sudo net rpc share list -U openhabian output:

openHAB-share
openHAB-conf
IPC$
openhabian