KISS 🇺🇦

Stop the war!

Stop the war in Ukraine! Fuck putin!

More information is at: https://war.ukraine.ua/.

There is a fund to support the Ukrainian Army: https://savelife.in.ua/en/donate/, and there is a special bank account that accepts funds in multiple currencies: https://bank.gov.ua/en/about/support-the-armed-forces. I donated to them. Please donate if you can!

Killer putin

Killer putin. Source: politico.eu.

Arrested putin

"It hasn't happened yet, but it will happen sooner or later. Beautiful photo, isn't it?" Source: twitter.

Configuring proxy in terminal in OS X

| comments

Sometimes you need to go to the internets through a proxy with authorization. And even in terminal on OS X.

First, you configure the proxy information in System Preferences / Network / Advanced / Proxies. There are Web Proxy Server, Username, and Password fields you fill in. It saves the credentials in the login keychain, so it makes sense to use them instead of typing them plaintext in terminal. To access the keychain, security program is used.

Having combined the command to set up proxy and get the credentials, here’s what I got:

1
2
3
4
5
6
PROXY='proxy.example.com';\
export http_proxy=\
$(printf $(security find-internet-password -s ${PROXY} | grep 'acct' | cut -d'"' -f4))':'\
$(security 2>&1 >/dev/null find-internet-password -gs ${PROXY} | cut -d'"' -f2)"@${PROXY}:8080" &&\
export https_proxy="$http_proxy" ftp_proxy="$http_proxy" HTTP_PROXY="$http_proxy"\
HTTPS_PROXY="$http_proxy" FTP_PROXY="$http_proxy"; unset PROXY

In the script above I added backslashes to split the command into multiple lines. It should work this way, but if it doesn’t remove the backslashes and merge the lines.

The script assumes the name of the item with the saved password is proxy.example.com, which is the address of your proxy and you should change it.

Note also the $(printf $(security …)) construction. Because in my case the username has the format domain\user, the security app returns domain\134user, where \134 is backslash escaping of \. printf converts it to the character itself. It may not be secure in general case!

NB! If you issue a command like echo "$https_proxy", it’ll show your username and password in plaintext. I haven’t figured out a way to avoid that yet.

mac

Note: The comments in the blog are provided by disqus.com; if you don't see the comment form under the post, probably your browser or its extension (such as uBlock Origin or NoScript) blocks their scripts.

« Unmount flash drive in OS X Jenkins and Qt »

Comments