0

I still haven't started this yet - just want to get some ideas, but can I access the directories and files on a Linux machine within a network using a C# Windows Service? I've read this and this, but so far, they are only trying to fetch the files inside the directory. My goal is:

  • Read if the files are existing
  • We expect the files to be zip files, so we the unzipping should happen on the Linux machine's directory
  • The Windows Service is deployed on the Windows machine with a FileSystemWatcher that will watch if the files on the Linux directory is created

I've read something about SSH and FTP libraries for C#, but isn't it only for getting the files? I want to interact with the files itself inside the directory.

Any helpful links or answers will be appreciated.

UPDATE:

I think one of the requirements is no using of Active Directory - which cancels out use of Samba.

Community
  • 1
  • 1
DustineTheGreat
  • 67
  • 1
  • 3
  • 11

2 Answers2

1

Samba setup guide

First update the server and install Samba:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install samba

Then wget this file: Samba config. Open it with your favorite text editor (i.e. nano on vi). REMEMBER TO SUDO THE EDITOR!!!

Find the following lines (and change the parameters to suit your needs):

[share]
   comment = A share
   path = /path/to/folder
   browsable = yes
   guest ok = no
   read only = no
   create mask = 0755

comment is a description for the share.

path is the path to the folder to share

browsable = yes makes the share and it's content browsable for authenticated users

guest ok = no disables anonymous login

read only = no enables editing and renaming files

create mask = 0755 sets the default permissions for new files


Then create user (and set password) for accessing the share:

sudo useradd share
sudo passwd share
sudo smbpasswd -a share
sudo smbpasswd -e share

Move your smb.conf to /etc/samba/smb.conf

sudo mv smb.conf /etc/samba/smb.conf

Reload Samba config:

sudo /etc/init.d/samba reload

OR If that doesn't work:

sudo smbd reload

Done!

Now you can access the share on windows using \\serverAddress\share

The username is WORKGROUP\share OR linuxServerHostname\share and password is the password you set above.

You can now map the share as network drive into Windows by going to explorer and use the "Map Network Drive"-wizard. There tick the checkbox "Connect using different credentials". You can map the network drive with C# as well.

All files and folders in the share now (when mapped) act as local files.

AirPett
  • 914
  • 1
  • 7
  • 17
0

Please make a Samba share on the remote Linux-machine, then the directory will act as a Windows share. Then you'd also be able to map it as a network drive and work with it the same way as local files.

AirPett
  • 914
  • 1
  • 7
  • 17
  • updated my post. i think the client don't want to use Active Directory, which is integrated by using Samba. – DustineTheGreat Jun 17 '15 at 06:22
  • Actually no, I have a lot of Samba shares at home and without AD. – AirPett Jun 17 '15 at 06:25
  • "Samba is an important component to seamlessly integrate Linux/Unix Servers and Desktops into Active Directory environments." quoted from samba.org. not really familiar with Linux, with all honesty, so I'm not sure how it will be implemented. – DustineTheGreat Jun 17 '15 at 06:30
  • This is a good link for making the Samba server: [Ubuntu Help](https://help.ubuntu.com/community/Samba/SambaServerGuide). I'll post another answer with essential details on how to get Samba up and running. – AirPett Jun 17 '15 at 06:46