# Passwords



### Stocker un mot-de-passe, un token dans la Keychain:

```bash
$ security add-generic-password -s gh_access_tokens -a bruno -w github_pat_xxyyzz
```

### Récupérer le mot-de-pass depuius la keychain:

```bash
$ security find-generic-password -w -s gh_access_tokens
github_pat_xxyyzz

$ gh_access_tokens=$(security find-generic-password -w -s gh_access_tokens)
```

### Supprimer un mot-de-passe, un token dans la Keychain:

```bash
$ security delete-generic-password -s gh_access_tokens -a bruno
keychain: "/Users/bruno/Library/Keychains/login.keychain-db"
.../...
password has been deleted.
```

https://scriptingosx.com/2021/04/get-password-from-keychain-in-shell-scripts/



```bash
$ security unlock-keychain -p API_KEYCHAIN_PASS KEYCHAINPATH

# API_KEYCHAIN_PASS	: mot de passe de session
# KEYCHAINPATH			: login.keychain, /Library/Keychains/System.keychain, ~/Library/Keychains/login.keychain
```



```bash
$ security lock-keychain KEYCHAINPATH
```

