Tag Archives: proxy

Working in OSX terminal behind a proxy

I am still a noob when it comes to the terminal so I am still trying to get a lay of the land.? Fortunately for me I have some friends from Upfront Wichita who are much more advanced and have all kinds of tips and tricks to inspire and challenge me.

One of the biggest challenges I run into is that I have to work through a proxy at my work computer.? I am on a mac using the terminal and often can’t use the same exact commands my compatriots can due to said proxy.? I am going to document the various cases that I run into periodically for posterity and to possibly help someone else who finds themself in the same boat.

Case 1:? Trying to install tmux following the instructions found here, but can’t run a simple curl command.? Here is my failed attempt output:

mac:build user$ curl -OL http://downloads.sourcforge.net/tmux/tmux-1.5.tar.gz
% Total??? % Received % Xferd? Average Speed?? Time??? Time???? Time? Current
Dload? Upload?? Total?? Spent??? Left? Speed
0???? 0??? 0???? 0??? 0???? 0????? 0????? 0 --:--:--? 0:00:17 --:--:--???? 0^C

I need to go THROUGH the proxy to download this file, but currently curl doesn’t know to do that.? I am sure there are several ways to do this, but this is the one I found and it works:

mac:build user$ curl -x 99.99.99.99:9999 -OL http://downloads.sourcforge.net/tmux/tmux-1.5.tar.gz
% Total??? % Received % Xferd? Average Speed?? Time??? Time???? Time? Current
Dload? Upload?? Total?? Spent??? Left? Speed
100? 7936? 100? 7936??? 0???? 0? 12467????? 0 --:--:-- --:--:-- --:--:-- 12497

You can read more about the -x option by typing ‘man curl’ in the terminal.? Man is just short for manual for all my noob comrades.

Bonus tip: Even better than the option listed above is setting up a proxy variable to be used every time curl is run.? To do so, go to your home directory by typing: cd ~/
Next create a new file with your text editor of choice (I will use vim) by typing: vim .curlrc

Note: the .curlrc is a hidden file that holds a set of run commands to be run when the program starts up every time.? Its like priming the engine of a lawn mower so it is ready to go when you yank the cord.? In this case we are making it “ready to go” by defining the proxy so we don’t have to every time the command is run.

Next in you text editor type this and save: proxy = 99.99.9.99:9999???? <–Except of course you need to replace the 9’s with your actual proxy address.? Don’t forget to set the appropriate port denoted by my ‘:9999’ at the tail of the address.

I believe a similar setup can work for other commands where you run into similar proxy issues.? I will each case as I come upon them and if an instance occurs that differs I will be sure to document my solution.

*******************
****UPDATE****
*******************

So I was unable to follow the later instructions listed above as I tried to unpack the tar.bz files I received errors and couldn’t resolve.?? I found another set of instructions that required homebrew first…which has a whole set of other issues in itself, but I have encountered this brew command enough times I thought I would give it a shot.

So far, its a no go with my proxy.? Here is my input command and the output that follows:

mac:local user$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
Press ENTER to continue or any other key to abort
==> Downloading and Installing Homebrew...
error: Could not resolve host: github.com; nodename nor servname provided, or not known while accessing https://github.com/mxcl/homebrew/info/refs?service=git-upload-pack
fatal: HTTP request failed
Failed during: git fetch origin master:refs/remotes/origin/master -n
mac:local user$

So… git needs to be configured for the proxy as well.? Type the following line to setup the proxy:

$ git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

…and for https…

$ git config --global https.proxy https://proxyuser:proxypwd@proxy.server.com:8080

Of course you will need to replace the proxy address with your own.? In my case it is an ip address so I use the schema 99.99.99.99:9999 and I do not need to include my username or proxy– perhaps because this is already setup in my mac network settings?

Once that is set, then I just type:

brew install tmux

And BOOM!? Done!

GEM INSTALL:

So I have run into yet another issue with my proxy and another subtle variation in how to deal with it:
I went to install tmuxinator using the following command:

mac:Safety-Concerns user$ gem install tmuxinator

But this resulting in a timeout.? So after some reading, I found that I have to set another http_proxy setting up as follows:
I tried: mac:~ user$ set HTTP_PROXY=99.99.99.99:9999 –but this didn’t work.
Then I found: mac:~ user$ export http_proxy=99.99.99.99:9999? — and that was the ticket!

After that I did one more command and installed tmuxinator succesfully:

mac:~ user$ sudo gem install tmuxinator
Password:
[...]
Thank you for installing tmuxinator

Good luck!