# How to setup remote work with x509 proxy
- Useful for working on your laptop or a HPC that's not managed for CMS
- Assumptions
- you are using conda to manage your working envs
- You followed the instructions [here](https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookStartingGrid) and have a valid key/cert in `.globus`
## Proxy
You might deal with two variations of the x509 proxy. The baseline obtained with `xrdgsitest` or`voms-proxy-init` is created without any extensions and might work for accessing some files, but it doesn't store the information about belonging to the CMS organization.
The second one contains a "voms extension" and is obtained by running `voms-proxy-init --voms cms`. **This one is necessary to access files from most CMS sites**.
- Fetch voms requirements
```bash
mamba install -c conda-forge ca-policy-lcg
mamba install -c conda-forge voms
```
- Fetch xrootd
```bash
mamba install -c conda-forge xrootd
```
- `xrdgsitest` utility is included which lets you check if your certifcate is working properly and generate the baseline proxy without extensions
- There are some dependencies which are currently not available as packages, so we'll have to copy them from `/cvmfs/grid.cern.ch/etc/grid-security/`
```bash
mkdir ~/.grid-security
scp -r lxplus:/cvmfs/grid.cern.ch/etc/grid-security/vomses ~/.grid-security
scp -r lxplus:/cvmfs/grid.cern.ch/etc/grid-security/vomsdir ~/.grid-security/
```
- Now `voms-proxy-init` needs to be pointed to the right directories, unfortunately while there is a `--vomses` CLI option, there isn't one for `--vomsdir` which has to be set in an environment variable
```
export X509_VOMS_DIR=~/.grid-security/vomsdir
voms-proxy-init --voms cms --vomses ~/.grid-security/vomses
```
- It's probably convenient to add an alias for this to your `.bashrc` e.g.
```
export X509_VOMS_DIR=~/.grid-security/vomsdir
alias proxy="voms-proxy-init --voms cms --valid 168:00 --vomses ~/.grid-security/vomses/"
```
or `dcms` for GermanGrid
```
alias proxy="voms-proxy-init --voms cms:/cms/dcms --valid 168:00 --vomses ~/.grid-security/vomses/"
```
## Using DAS/dasgoclient locally
- *dasgoclient* is luckily standalone and not dependent on CMSSW and can be found [here](https://github.com/dmwm/dasgoclient), however since the instructions are a bit confusing here's a more complete set.
- It does, however, require go, but worry not, you can install it in conda.
```bash
mamba install -c conda-forge go
```
- You also need to define where to store the packages
```
mkdir ~/.go
```
and add the following line to your `~/.bashrc`
```
export GOPATH=~/.go # ideally use absolute path
```
- Download requirements
```bash
# go install github.com/dmwm/cmsauth@latest
go install github.com/dmwm/das2go@latest
go install github.com/vkuznet/x509proxy@latest
go install github.com/buger/jsonparser@latest
go install github.com/pkg/profile@latest
```
- Checkout dasgoclient and build
```
git clone https://github.com/dmwm/dasgoclient.git
cd dasgoclient
make build_all
```
- This creates several executables, so pick the one appropriate for your system
```
./dasgoclient_linux -query="dataset=/ZMM*/*/*"
```
- Add an alias to your `.bashrc` again
```
alias dasgoclient="/home/anovak/software/dasgoclient/dasgoclient_amd64"
```