You are not logged in.
Hey,
I'm trying to set up my laptop running arch to work with network at work.
I got a working settings in /etc/network.d/ and I am able to do a netcfg mynetwork and connect.
Only thing bugging me is proxy. If I set it up inside Opera browser, it's all fine, but I can't access internet from terminal.
Proxy requires authentication.
I followed this article - https://wiki.archlinux.org/index.php/Pr … _variables
If I use this method (I changed the 'proxyserver' to my proxy address):
function proxy(){
echo -n "username:"
read -e username
echo -n "password:"
read -es password
export http_proxy="http://$username:$password@proxyserver:8080/"
export https_proxy="http://$username:$password@proxyserver:8080/"
export ftp_proxy="http://$username:$password@proxyserver:8080/"
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
echo -e "\nProxy environment variable set."
}
function proxyoff(){
unset HTTP_PROXY
unset http_proxy
unset HTTPS_PROXY
unset https_proxy
unset FTP_PROXY
unset ftp_proxy
echo -e "\nProxy environment variable removed."
}(which btw I think it contains an error, flag for 'read password' should be just -s)
and I run a proxy (after sourcing it and typing in username and pw) I get a "Proxy environment variable set."
But when I try to ping something, it just hangs.
The second method (I changed username and serveraddress:port):
#!/bin/bash
assignProxy(){
PROXY_ENV="http_proxy ftp_proxy https_proxy all_proxy no_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY NO_PROXY ALL_PROXY"
for envar in $PROXY_ENV
do
export $envar=$1
done
}
clrProxy(){
assignProxy "" # This is what 'unset' does.
}
myProxy(){
user=YourUserName
read -p "Password: " -s pass && echo -e " "
proxy_value="http://$user:$pass@ProxyServerAddress:Port"
assignProxy $proxy_value
}gives the following error:
assignProxy:export:4: not valid in this context: http_proxy ftp_proxy https_proxy all_proxy no_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY NO_PROXY ALL_PROXYSo, what is my next step?
Thanks
Last edited by developej (2013-03-04 12:29:09)
Offline
But when I try to ping something, it just hangs.
Ping is not a way to test proxy connections (well, you can test if the proxy answers your ICMP requests, but nothing more). Use curl or wget or anything the does a HTTP request and is aware of proxies.
Offline
Oh, ok. I tried wget after I did a proxy() (first script listed above), entered username, password, and got a "Proxy environment variable set." and then I get this:
Error parsing proxy URL http://:MYPASSWORD@10.0.4.25:8080/: Invalid user name.It seems to me that there is something wrong with the script - even though it asks me for username, it doesn't make an environment variable with it.
My user name is in the form "domain/name.surname", but I tried a 'simpler' one - "test", and it still sets the environment variable without it.
I can't find error in script...
edit: I tried to do it manually too:
export http_proxy="http://name:password@ip:port/"and then tried a wget - it complains
ERROR 407: Proxy Authentication Required.Last edited by developej (2013-03-04 12:09:09)
Offline
Ok, got it sorted out.
First I used printenv command to see what exactly is set...and then I figured out that the correct way to enter username is:
domain\\username:password
One has to escape the "\" after domain...
wget worked.
Marking as solved, thanks.
btw, script still doesn't work for me...will have to look into that ![]()
edit: since I use proxy only at work (for now), I tweaked the script not to ask for username and password - I made a function proxywork() with everything set up. When (if) I have to use some other proxy, I will add another function "proxy2()" or something...and I left one unique proxyoff() function to remove all variables.
Last edited by developej (2013-03-04 12:46:26)
Offline