nix:proxy
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
nix:proxy [2016/06/03 11:00] – created kauffman | nix:proxy [2021/01/14 14:10] – kauffman | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Proxy ====== | ====== Proxy ====== | ||
Sometimes you will be on a machine without access to the internet and you need to get a file downloaded. You could first download the file somewhere else and then transfer it to the machine on the private network. This get tedious... hence the reason for this article. | Sometimes you will be on a machine without access to the internet and you need to get a file downloaded. You could first download the file somewhere else and then transfer it to the machine on the private network. This get tedious... hence the reason for this article. | ||
+ | |||
+ | Some notes before we begin: | ||
+ | - Anywhere CS infrastructure is specified it may be possible to substitute any similar UNIX host. | ||
+ | - I assume you use the ' | ||
+ | |||
+ | ===== Initial setup ===== | ||
+ | If you have not done so already you will need to setup [[techstaff: | ||
Line 6: | Line 13: | ||
Read up on SOCKS proxies here: https:// | Read up on SOCKS proxies here: https:// | ||
- | ==== Initial | + | Where the port number is set to ' |
- | If you have not done so already you will need to setup [[techstaff: | + | |
+ | Now we can create a SOCKS proxy without a password: | ||
+ | < | ||
+ | user@computer: | ||
+ | </ | ||
+ | |||
+ | Notice how the ssh session is now running in the background: | ||
+ | < | ||
+ | user@computer: | ||
+ | user 11995 0.0 0.0 58240 1016 ? Ss | ||
+ | user 11997 0.0 0.0 11740 916 pts/2 S+ | ||
+ | </ | ||
+ | |||
+ | Set the '' | ||
+ | < | ||
+ | user@computer: | ||
+ | </ | ||
+ | |||
+ | Any tool that respects this environment variable will tunnel its traffic through the proxy we just setup. | ||
+ | < | ||
+ | user@computer: | ||
+ | Cloning into ' | ||
+ | remote: Counting objects: 120662, done. | ||
+ | remote: Compressing objects: 100% (48/48), done. | ||
+ | remote: Total 120662 (delta 23), reused 0 (delta 0), pack-reused 120608 | ||
+ | Receiving objects: 100% (120662/ | ||
+ | Resolving deltas: 100% (74544/ | ||
+ | Checking connectivity... done. | ||
+ | Checking out files: 100% (1456/ | ||
+ | </ | ||
+ | ==== Automatically | ||
+ | Now to make it automatic on login. | ||
+ | Add the following to ~/.profile or ~/ | ||
+ | Remove the ' | ||
+ | |||
+ | < | ||
+ | if [[ $(nc -z 127.0.0.1 20000; echo $?) -eq 0 ]]; then | ||
+ | echo ' | ||
+ | else | ||
+ | echo ' | ||
+ | ssh -f -C -q -N -D20000 user@linux.cs.uchicago.edu | ||
+ | export ALL_PROXY=' | ||
+ | fi | ||
+ | </ | ||
+ | |||
+ | ===== Git ===== | ||
+ | First you will need to setup [[techstaff: | ||
+ | |||
+ | Add the following | ||
+ | * Replace '' | ||
+ | * Replace '' | ||
+ | |||
+ | < | ||
+ | Host github.com | ||
+ | User CNETID | ||
+ | ProxyCommand ssh -i ~/ | ||
+ | IdentityFile ~/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== HTTP(S)===== | ||
+ | You can also use our HTTP proxy server. | ||
+ | |||
+ | ==== Setup ==== | ||
+ | In the shell type the following: | ||
+ | < | ||
+ | export http_proxy=http:// | ||
+ | export https_proxy=https:// | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== SSH Port Forwarding ===== | ||
+ | This has many uses, but one use case we see a lot is to proxy a database connection. | ||
+ | |||
+ | You can also do some port forwarding magic with ssh. This is known to work on macOS and Linux based OS' | ||
+ | |||
+ | The following command will open an ssh session to one of the linux machines. Once you've signed in, you can minimize this terminal window. Port 5432 on your local machine has been forwarded through the SSH connection to port 5432 on $dbserver. | ||
+ | |||
+ | < | ||
+ | user@mymachine: | ||
+ | </ | ||
+ | |||
+ | Now by connecting to localhost: | ||
+ | |||
+ | < | ||
+ | user@mymachine: | ||
+ | </ | ||
+ | |||
+ | ====== SSHFS ====== | ||
+ | |||
+ | * [[https:// | ||
+ | |||
+ | This tutorial assumes mac or linux. See the community tutorial if you wish to use windows. | ||
+ | ==== Install SSHFS ==== | ||
+ | Debian/ | ||
+ | < | ||
+ | apt-get install sshfs | ||
+ | </ | ||
+ | MacOS: | ||
+ | Download and install both packages from this site: https:// | ||
+ | ==== Create Local directory ==== | ||
+ | Create a directory on your local machine to which you wish to mount your CS home directory to. | ||
+ | < | ||
+ | mkdir $HOME/ | ||
+ | </ | ||
+ | ==== Mount ==== | ||
+ | < | ||
+ | sshfs -o idmap=user, | ||
+ | </ | ||
/var/lib/dokuwiki/data/pages/nix/proxy.txt · Last modified: 2021/01/19 09:52 by kauffman