Securely Connecting to a Remote SMB Server

by Charlton Rose

Once I was in a predicament. I was working from home, and I desperately needed to map a drive on my computer to a server at work. Unfortunately, all the computers at work were behind a firewall. However, I had previously convinced the system administrator to poke a small hole in the firewall for SSH connections to the Linux workstation in my office.

So I came up with what I thought was a clever solution. I stopped SMB on my home Linux box, set up an SSH tunnel for the SMB ports to the remote SMB server, and then mapped a drive, through that tunnel, from my home Windows machine to the remove SMB server.

This is the script I ran on my home Linux box:

REMOTE_SSH_HOST=___.___.___.___ # fill in IP address here
REMOTE_SMB_HOST=___.___.___.___ # fill in IP address here
/etc/rc.d/init.d/smb stop
ssh -g \
	-L 137:$REMOTE_SMB_HOST:137 \
	-L 138:$REMOTE_SMB_HOST:138 \
	-L 139:$REMOTE_SMB_HOST:139 \
/etc/rc.d/init.d/smb start

man ssh for details. It worked like a charm, and the connection was totally secure, even over an insecure internet. Telecommuting's not so bad when you can work like this!

Copyright © 2000 Sharkysoft. All rights reserved.

[ Sharkysoft home | more Linux tips ]