Setting Proxy Environment in UNIX
The easiest and best way to set proxy information on your Linux/Unix machine is with the http_proxy environment variable in your ~/.bashrc, ~/.zshrc, or whatever your favorite shell’s configuration file is. Set it like this:
http://user:password@proxy-server:portnum
In my brief bit of experimentation, the follow important (to me, at least) command-line tools use http_proxy:
- wget
- Python easy_install
- curl
I’ve been a Unix user for 14 years — why did I take me so long to figure this out?
How SSH knows how to get your keys
Most people who work with SSH know that your user’s keys and config is at $HOME/.ssh. Or is it? A problem I had revealed that it isn’t so cut-and-dried.
I use Cygwin at work, because, well, I need to get work done. I was smart enough a long while back to make my users HOME directory my shared H-drive, as opposed to somewhere on the C-drive. That way if I got a new machine, etc my configs would be safe.
Well, the moment arrived to see if that worked. I got a new hard drive at work a month or so ago and one of the first things I did was install Cygwin. Everything worked great — except my SSH keys. For some reason, Cygwin’s SSH refused to find my private keys, even though I have never moved them. This week I finally dug in to figure out what happened.
I did a ssh -v host and saw this:
debug1: Trying private key: /cygdrive/c/.ssh/identity
Huh? My HOME directory is set to H (/cygdrive/h/, in Cygwin-speech). I mucked around again and it will was in the wrong spot. A few google searches later revealed that OpenSSH doesn’t look at the $HOME environment variable at all! Instead it goes by the directory for the user in /etc/passwd. I opened that up and, sure enough, it was set to “/cygdrive/c/“. I changed it, saved the file and then it worked.
In an normal Unix instance, this works because, chances are, they will be the same. But I guess when I installed Cygwin I didn’t have a HOME variable set, so it defaulted it to the C-Drive. Then when I set it to the H-drive, it just happily used that and let things break.