Store and share passwords among Linux, Mac and Windows in a local network

codeprototype

Kevin Le

Posted on July 18, 2021

Store and share passwords among Linux, Mac and Windows in a  local network

There are many cloud-based Password Manager solutions, free and paid. One of the free ones I like the most is BitWarden. Then there's also KeePass 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. 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.

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

Make it executable by calling chmod:

chmod +x pash
Enter fullscreen mode Exit fullscreen mode

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)

Enter fullscreen mode Exit fullscreen mode

Mac

On a Mac, GnuPG is not installed by default, so we must first install it:

brew install gnupg gnupg2
Enter fullscreen mode Exit fullscreen mode

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

Windows

On Windows, we need Windows 10 Pro edition. Then install WSL2.

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
Enter fullscreen mode Exit fullscreen mode

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/
Enter fullscreen mode Exit fullscreen mode

and

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

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

Run pashpush and pashpull is easy

pashpush some-password
pashpull another-password
Enter fullscreen mode Exit fullscreen mode

Alternatively if you don't like CLI, there are GUI options such as WinSCP on Windows and Transmit by Panic on Mac and Filezilla on both.

💖 💪 🙅 🚩
codeprototype
Kevin Le

Posted on July 18, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related