Transfer files between a Sweex/Edimax router and a remote PC

This page records how to set up Samba and FTP services (also see my note on wget)

Samba lets PCs and Macs on your LAN open windows containing the contents of the folders in the memory stick - you can then use a PC/Mac text processor or html editor to modify the files directly on a live Sweex/Edimax router.

FTP lets you transfer complete files back and forth across the wider internet. I like Fireftp (within the Firefox browser) since it is the same on any platform.

Samba is easier to use but took some time to set up as I wanted. A powerful "context coloured" text editor (like BBedit on the Mac) makes developing Blassic and ash control programs (etc) very easy.

1) Make sure the Sweex has a fixed LAN address and can connect to the internet
- set the following in the files on the USB memory stick
etc/midge.conf is set so that the 5 ethernet ports are all at one local LAN address (I use 192.168.0.3)
the line

VLAN_MX="0x5F,0,0,0,0,0" # 1 ethernet iface (5LAN)
should NOT have a # at the start
etc/network/interfaces should contains this -
auto eth0
iface eth0 inet static
address 192.168.0.3
<- change this
netmask 255.255.255.0
gateway 192.168.0.230
<- change this to your ADSL gateway LAN address
(remove the rest)

etc/resolv.conf
on the memory stick should point to the DNS server.
I use my ADSL modem to provide DNS to my LAN at 192.168.0.230
So the file resolv.conf contains just -

# domain ci.ukrpack.net <-not used by me
nameserver 192.168.0.230

Thanks to Picprojects for help in setting up Samba- you may prefer to use his Tutorial
Picprojects notes that Nano is a very simple text editor for use via a Telnet session
- I agree - no need to read a help file, just use it!

2) ipkg  - lets you add programs to the memory stick - no need to recompile the Sweex firmware

First update /etc/ipkg.conf so that the following source lines are active

src picprojects http://www.picinternetprojects.247n.com/packages
src picprojectsSDK http://www.picinternetprojects.247n.com/packages/sdk
src kamikaze http://midge.vlad.org.ua/kamikaze/20061223/bin/packages


3) nano - a very easy to use text editor that lets you modify a live router within a Telnet session.

In a terminal window type -

telnet 192.168.0.3 - use user root and password midge
ipkg update
ipkg install nano
then
nano etc/filename or similar to edit a file, control-X to finish


4) samba

In a terminal window type -

telnet 192.168.0.3 - use user root and password midge
ipkg update
ipkg install samba
mkdir /var/run
smbpasswd -a graham
<-creates user graham in my case- provide a password when asked.
nano /etc/hosts
add the line '192.168.0.3 midge' (192.168.0.3 is the LAN address of the router)
nano /etc/samba/smb.conf
alter the last line writeable = no to writeable = yes

/etc/samba/smb.conf

[global]
syslog = 0
syslog only = yes
workgroup = WORKGROUP
server string = Midge Samba Server
security = share
encrypt passwords = yes
guest account = nobody
local master = yes
name resolve order = lmhosts hosts bcast

[data]
comment = /data
path = /data
browseable = yes
public = yes
writeable = yes

[var]
comment = /var
path = /var
browseable = yes
public = yes
writeable = yes

[etc]
comment = /etc
path = /etc
browseable = yes
public = yes
writeable = yes

Test it
/etc/init.d/samba start
Use
PC - "My Network Places " to find the shared files on your LAN
Macintosh - click on go menu - Connect to server - Browse

If all OK make Samba come up at boot time
mv /etc/init.d/samba /etc/init.d/S97samba

BUT also see note 6 below


5) ftp

Many thanks to gpolder for help (see the thread "FTP" on the discussion board on this site)

In a terminal window type -

telnet 192.168.0.3 - use user root and password midge
ipkg update
ipkg install vsftpd
mv /etc/init.d/vsftpd /etc/init.d/S51vsftpd
reboot


in an FTP program
use
user - root
password - midge

(the same as for Telnet)

 

6) Some notes on users and permissions - and some Samba problems

Adding a new user to the router for ftp and samba
I started with this

http://midge.vlad.org.ua/forum/viewtopic.php?t=403&highlight=adduser
and
http://www.ibm.com/developerworks/linux/library/l-roadmap4/

procedure
open etc/passwd in a text editor and add -

graham:x:1001:1000:graham:/home/graham:/bin/ash
(then the next user you add is 1002:1000)

I gave graham's directory and the /home directory permission 777

Give graham a password
- in a Telnet session -

midge# passwd graham
Changing password for graham
Enter the new password (minimum of 5 characters)
Please use a combination of upper and lower case letters and numbers.
Enter new password: <I typed a password here>
Re-enter new password: <and here>
Password changed
.

in etc/passwd I now see something a bit like -
graham:qdc876wqec77cqo1DYiT7pv5Y.:1001:1000:graham:/home/graham:/bin/ash

I opened a new ftp session using the Fetch ftp client on my Mac
I logged in as graham (with his password)
I found I was in the /home/graham folder
that I had made earlier

But as graham I have full read access to ALL folders
I also tried a session with the wrong password and it would not let me in, as expected.

Samba

In a Telnet session I typed
smbpasswd -a graham
to create a samba user called 'graham'
I set a password as requested
(graham also has to be in the main password file)

In /etc/hosts I added the line '192.168.0.4 midge04'

In /etc/samba/smb.conf I altered the last line
writeable = no to writeable = yes

graham can then see the contents of but not write to any folders that are set to 777 security

You also have to give root a Samba password - the Telnet session was -
midge03# smbpasswd root
New SMB password:
Retype new SMB password:
Password changed for user root.
midge03#

Even so, with the default contents of /etc/samba/smb.conf root can only save files to folders that are set to 777
- so I
changed security = user to security = root in order to allow root to write files in any folder
(thanks to MRX) or you can also change guest account = nobody to guest account = root (thanks to gedoe)
the former sounds like better security but both seem to have the same effect in my tests....

TIP If you have two Sweex/Edimax routers on the network change their names in /etc/hostname

The following lets root see and write to any folder in the USB memory stick and lets graham see it all but only write to 777 folders.

/etc/samba/smb.conf

[global]
syslog = 0
syslog only = yes
workgroup = WORKGROUP
server string = MidgeSamba04
security = user
encrypt passwords = yes
guest account = nobody
local master = yes
name resolve order = lmhosts hosts bcast

[all_files_04]
comment = /
path = /
browseable = yes
public = yes
writeable = yes

 


Please email me with errors and improvements
- these are my personal notes of what I have recently learned from the experts to whom many thanks
- here for my future reference and for any help they may give others