Update FreeBSD Using Proxy Server (csup / portsnap proxy update)

Posted on in Categories , , last updated November 19, 2008

Question: How do I upgrade my FreeBSD server and ports tree using our proxy server, which requires username and password based authentication?

Answer: You have various choice under FreeBSD.

Use http_proxy shell variable

Linux / UNIX has environment variable called http_proxy. It allows you to connect text based session / application via the proxy server (bash compatible shell export syntax):
export http_proxy='http://user:[email protected]:port/'
export http_proxy='http://vivek:[email protected]:3128/'

Now, you can run portsnap ports update utility or csup command easily:
# portsnap fetch update
# csup /path/to/supfile

prtunnel tunnels

If above method failed use prtunnel to set tunnels. It is a TCP connection through to a remote server using an HTTP or SOCKS5 proxy. It is useful if you are behind a proxy and want to use a program that doesn’t have native proxy support.

Install prtunnel tunnel proxy software

First, get access via proxy, enter:
# export http_proxy='http://user:[email protected]:3128/'
Type the following command to install :
# cd /usr/ports/net/prtunnel
# make install clean

How do I use prtunnel?

Type the command as follows:
# prtunnel --password-prompt -t http -H -P 3128 -D 5999 cvsup1.FreeBSD.org 5999
It will prompt for proxy username and password. If you do not wish, prompt try as follows:
# prtunnel -u 'username' -p 'myPassword' -t http -H -P 3128 -D 5999 cvsup1.FreeBSD.org 5999
Once connected, open supfile:
# vi /path/to/supfile
And set default host to *default host=
*default host=localhost
*default host=
Save and close the file. After starting prtunnel like this, you could then point supfile to, and prtunnel will attempt to connect you to cvsup1.FreeBSD.org via the HTTP proxy server on a system named “” with given username and password. Now run csup, enter:
# csup /path/to/supfile

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

1 comment

Leave a Comment