Store and share passwords among Linux, Mac and Windows in a  local network
Tags: linux, macos, wsl2
Published: 2021-07-18 14:12:45

There are many cloud-based Password Manager solutions, free and paid. One of the free ones I like the most is [BitWarden](https://bitwarden.com/). Then there's also [KeePass](https://keepass.info/) which I think is only a desktop application. Those are battlefield-tested solutions. Before I go on, I'd recommend you would consider those solutions as well. 

But those solutions do not meet the requirements for my use case. I use all 3 kind of computers Linux, Mac and Windows. The motivation for me is at any given time, when I'm prompted for a password, I want to have a quick and convenient way to retrieve it, regardless of which computer and OS I happen to be on. For me that would be using a [CLI](https://en.wikipedia.org/wiki/Command-line_interface). Secondly, I do not want my passwords to leave my local network. Finally, if I create a new password on one computer, I want to be able to replicate it to all of my computers.

The core of my solution is a simple Password Manager called [pash](https://github.com/dylanaraps/pash).

## Installation
### Linux
There's no installation. On Linux, simply create an `executable file` at `/usr/local/bin` called `pash` and copy the content from [https://github.com/dylanaraps/pash/blob/master/pash](https://github.com/dylanaraps/pash/blob/master/pash)

Make it executable by calling `chmod`:

```
chmod +x pash
```
Using `pash` is easy. Just type `pash` and it will show how to use it.

```
$ pash
pash 2.3.0 - simple password manager.

=> [a]dd  [name] - Create a new password entry.
=> [c]opy [name] - Copy entry to the clipboard.
=> [d]el  [name] - Delete a password entry.
=> [l]ist        - List all entries.
=> [s]how [name] - Show password for an entry.
=> [t]ree        - List all entries in a tree.

Using a key pair:  export PASH_KEYID=XXXXXXXX
Password length:   export PASH_LENGTH=50
Password pattern:  export PASH_PATTERN=_A-Z-a-z-0-9
Store location:    export PASH_DIR=~/.local/share/pash
Clipboard tool:    export PASH_CLIP='xclip -sel c'
Clipboard timeout: export PASH_TIMEOUT=15 ('off' to disable)

```
### Mac
On a Mac, `GnuPG` [is not installed by default](https://stackoverflow.com/a/27042267/1244013), so we must first install it:

```
brew install gnupg gnupg2
```

Then carry out the rest just like in the Linux section above.

### Windows
On Windows, we need Windows 10 Pro edition. Then [install WSL2](https://duckduckgo.com/?t=ffab&q=install+wsl2+windows+10&ia=web).

Again, carry out the rest just like in the Linux section above.

## Replication
Now I can create a password on any one of the computers, be it Linux, Mac or Windows. Next I want to replicate it easily to the rest of the computers in my local network. In that way, the passwords are always available. Since I do not want the passwords to leave my local network, I don't want to copy to Google Drive or OneDrive or something like that. And since I want the replication process to be easy, I don't want to copy to a USB drive, eject, carry around, plug back in, etc.

What I will do is install OpenSSH server on my Linux computer, which seems like the most sensible approach.

```
sudo apt install openssh-server
```

Then on my Mac and  Windows/WSL2, I just create a couple of executable files called `pashpush` and `pashpull` in `\usr\local\bin` directory.

```
#!/bin/sh
#
# pashpush
scp ~/.local/share/pash/$1.gpg kevin@linux-host:~/.local/share/pash/
```

and

```
#!/bin/sh
#
# pashpull
scp kevin@linux-host:~/.local/share/pash/$1.gpg ~/.local/share/pash/
```

Then run `chmod +x` as before with the program `pash`.  

Run `pashpush` and `pashpull` is easy

```
pashpush some-password
pashpull another-password
```

Alternatively if you don't like CLI, there are GUI options such as [WinSCP](https://winscp.net/eng/index.php) on Windows and [Transmit by Panic](https://panic.com/transmit/) on Mac and [Filezilla](https://filezilla-project.org/) on both.