December 6th, 2004, 09:20 AM
Samba over SSH
Tunneling through SSH has already been somewhat covered here on AO.
Also, there is a thread about samba over ssh, but not very detailed.
Here, I'd like to show how to access securely (using SSH tunnels) a samba
server from a Windows XP pro client, by mapping a network drive.
The authorisation as well as the file-transfer procedure is then encrypted.
Maybe this makes sense in some context, maybe it's just for fun. Note, that
sftp might be a better solution for your purposes.
Typical setup Home Lan:
-ssh-server 192.168.1.10 <-...-> 188.8.131.52 (public IP)
Why samba: A guy, somewhere in the Internet, needs a samba share from 184.108.40.206, but for
obvious reasons, 137-139,445 are blocked at 220.127.116.11. Maybe he wants to listen to music
on that samba share and his player-software needs a network drive.
Why SSH: SSH tunneling is a good choice - there are even some people here tunneling VNC over SSH.
We won't use some stunnel-solution, but either putty or the tectia client.
We try to establish a local ssh tunnel connection in the sense of
Note: We establish a connection from 139 to 139.
ssh firstname.lastname@example.org -L 139:192.168.1.11:139
let's do it
NetBIOS on 139?
Since we want create a network drive, we need access to 139 on the first hand.
Type in a command shell:
Add a SSH tunnel (evaluated at 192.168.1.10!):
Destination Port: 139
Establish the SSH connection.
should show a line like
where tasklist /SVC shows that 1572 = Putty/SshClient
TCP 127.0.0.1:139 0.0.0.0:0 LISTENING 1572
should show an empty display. If this test is successful, the connection is established!
telnet 127.0.0.1 139
Close the telnet terminal.
where sharename is the shared folder name on the samba server, eg. "public".
net use z: \\127.0.0.1\sharename [/user:username2]
If we do not need the connection anymore, we could restart the server service:
If you encounter any problems, please inform me.
I tested the whole setup, but cannot guarantee its
working for all windows versions.
If the only tool you have is a hammer, you tend to see every problem as a nail.
(Abraham Maslow, Psychologist, 1908-70)