Socks5 แบบใช้ PAM (Debain 7 & ubuntu 12.04)

What should be done:

  1. Install Dante server and PAM library
  2. Edit Dante configuration file “/etc/danted.conf”
  3. Add PAM configuration file
  4. Create user accounts
  5. Start the server and check settings
  6. Troubleshoot

1. Install Dante server and PAM library

I wanted to restrict access to my SOCKS server but didn’t want to add local users and authenticate against them. Also IP based restriction was out of the question as our users IP is dynamic. A PAM (Pluggable Authentication Module) library would be ideal for that regard. To install, run the following command:

2. Edit Dante configuration file

Back up the original configuration file

Open vim or your favorite text editor

Copy and paste following lines. Its very simple configuration that allows every client with an account to access the server so you may want to edit this so it fits your needs.

You can read more about Dante server configuration here.

3. Add PAM configuration file

When I installed Dante, it didn’t create any file in “/etc/pam.d” folder but if there is any, we need to make a back up.

and create a new file

Copy and paste following lines and save the file

4. Create user accounts

I used htpasswd to register users so I assumed that you have apache2 installed on your server. We have to create a folder to put our virtual accounts database there.

then use following command to register users

if cannot find htpasswd command user this command “sudo apt-get install apache2-utils

The command will ask you for a password. Minor problem with htpasswd command is that your passwords can not be larger than 8 characters.

-c argument will make new file and -d will force MD5. For creating additional users you only need to use -d argument.

5. Starting server

To start the server enter following command

To stop the server

If you’re lucky enough your server will start without any problems. If not please refer to troubleshooting step.

To test your server you need a SOCKS 5 client that could handle authentication. I don’t know about linux but you can use Proxifier if you’re using windows.

6. Troubleshooting

The only problem I encountered while setting up the server was getting following error after started the server:

After a bit of digging I found out that this is a bug exist in Ubuntu 12.04. Anyway you can solve the problem with below command

Hope this helps some people who had trouble setting up Dante server.

Source http://devmash.net/setup-dante-server-with-virtual-user-accounts-on-ubuntu/
and http://www.linuxquestions.org/questions/linux-networking-3/unable-to-find-htpasswd-command-932076/

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.