<commit_before># SSH Notes #


## Articles/Resources ##

- http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html
- http://lifepluslinux.blogspot.com/2017/01/look-before-you-paste-from-website-to.html

## Sign / Verify ##


```
openssl genrsa -out private.pem 1024
openssl rsa -in private.pem -out public.pem -outform PEM -pubout
```

```
  echo -n "data-to-sign" | openssl dgst -RSA-SHA256 -sign private.pem > signed
  base64 signed
```


## Port Forwarding ##

Remote Port Forwarding

````
  ssh -nNR 80:localhost:8080 hostname &
  echo $!

  kill $!
```


Check for existing SSH tunnels

```
  ps aux | grep ssh
```


## Gitlab Setup ##
`git clone gitlab:user/repo.git`

```ssh
  Host gitlab
    User git
    HostName gitlab.com
    IdentityFile ~/.ssh/gitlab.pem
  #  IdentitiesOnly yes
```


## SSH Config ##

```
  LocalForward 5433 localhost:5432
  ProxyCommand ssh gateway -W %h:%p
  
  # Speed up ssh connections
  GSSAPIAuthentication no
  IdentitiesOnly yes
```


## Setup LDAP SSH Access ##

- https://eng.ucmerced.edu/soe/computing/services/ssh-based-service/ldap-ssh-access

<commit_msg>Add ssh notes on how to run a script on remote server<commit_after># SSH Notes #


## Articles/Resources ##

- http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html
- http://lifepluslinux.blogspot.com/2017/01/look-before-you-paste-from-website-to.html

## Sign / Verify ##


```
openssl genrsa -out private.pem 1024
openssl rsa -in private.pem -out public.pem -outform PEM -pubout
```

```
  echo -n "data-to-sign" | openssl dgst -RSA-SHA256 -sign private.pem > signed
  base64 signed
```


## Run Script ##

Running a script on a remote server

```bash
ssh user@host 'bash -s' < /path/script.sh
```
Or

```bash
cat /path/script.sh | ssh user@host 'bash -s'
```


## Port Forwarding ##

Remote Port Forwarding

````
  ssh -nNR 80:localhost:8080 hostname &
  echo $!

  kill $!
```


Check for existing SSH tunnels

```
  ps aux | grep ssh
```


## Gitlab Setup ##
`git clone gitlab:user/repo.git`

```ssh
  Host gitlab
    User git
    HostName gitlab.com
    IdentityFile ~/.ssh/gitlab.pem
  #  IdentitiesOnly yes
```


## SSH Config ##

```
  LocalForward 5433 localhost:5432
  ProxyCommand ssh gateway -W %h:%p
  
  # Speed up ssh connections
  GSSAPIAuthentication no
  IdentitiesOnly yes
```


## Setup LDAP SSH Access ##

- https://eng.ucmerced.edu/soe/computing/services/ssh-based-service/ldap-ssh-access




{'fraction_non_alphanumeric': 0.14336633663366335, 'fraction_numerical': 0.029306930693069305, 'mean_word_length': 3.2525252525252526, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2151174', 'n_tokens_mistral': 1048, 'n_tokens_neox': 890, 'n_words': 218}