Pass: Difference between revisions
No edit summary |
m (Text replacement - "<source" to "<syntaxhighlight") |
||
Line 10: | Line 10: | ||
====Obvious way==== | ====Obvious way==== | ||
< | <syntaxhighlight lang=bash> | ||
$ pass -c Customers/CustomerA/myuser@sshhost | $ pass -c Customers/CustomerA/myuser@sshhost | ||
$ ssh myuser@sshhost | $ ssh myuser@sshhost | ||
Line 20: | Line 20: | ||
=====Create an alias===== | =====Create an alias===== | ||
< | <syntaxhighlight lang=bash> | ||
$ alias customerA-sshhost='sshpass -f <(pass Customers/CustomerA/sshuser@sshhost) ssh sshuser@sshhost' | $ alias customerA-sshhost='sshpass -f <(pass Customers/CustomerA/sshuser@sshhost) ssh sshuser@sshhost' | ||
</source> | </source> | ||
=====Use it===== | =====Use it===== | ||
< | <syntaxhighlight lang=bash> | ||
$ customerA-sshhost | $ customerA-sshhost | ||
sshuser@sshhost:~$ | sshuser@sshhost:~$ | ||
Line 34: | Line 34: | ||
====Obvious way==== | ====Obvious way==== | ||
< | <syntaxhighlight lang=bash> | ||
$ pass -c Customsers/CustomerB/mysqluser@mysqlhost:mysql | $ pass -c Customsers/CustomerB/mysqluser@mysqlhost:mysql | ||
$ mysql -h mysqlhost -u mysqluser | $ mysql -h mysqlhost -u mysqluser | ||
Line 45: | Line 45: | ||
=====Create an alias===== | =====Create an alias===== | ||
< | <syntaxhighlight lang=bash> | ||
$ alias customerB-mysqlhost-mysqluser='mysql --user mysqluser --host mysqlhost --password=$(pass show Customsers/CustomerB/mysqluser@mysqlhost:mysql)' | $ alias customerB-mysqlhost-mysqluser='mysql --user mysqluser --host mysqlhost --password=$(pass show Customsers/CustomerB/mysqluser@mysqlhost:mysql)' | ||
</source> | </source> | ||
Or even cooler with seperate history and defaults file per connection | Or even cooler with seperate history and defaults file per connection | ||
< | <syntaxhighlight lang=bash> | ||
$ mkdir -p ~/Customsers/CustomerB/.mysql | $ mkdir -p ~/Customsers/CustomerB/.mysql | ||
$ cat > ~/Customsers/CustomerB/.mysql/.my.cnf-mysqlhost-mysqluser << EOF | $ cat > ~/Customsers/CustomerB/.mysql/.my.cnf-mysqlhost-mysqluser << EOF | ||
Line 61: | Line 61: | ||
=====Use it===== | =====Use it===== | ||
< | <syntaxhighlight lang=bash> | ||
$ customerB-mysqlhost-mysqluser | $ customerB-mysqlhost-mysqluser | ||
... | ... |
Revision as of 15:38, 25 November 2021
pass - The standard unix password manager
Tipps & Tricks
SSH
To pass the password to the ssh password promt you need another tool, too: sshpass . Put only the password in your Customers/CustomerA/myuser@sshhost.
Obvious way
<syntaxhighlight lang=bash> $ pass -c Customers/CustomerA/myuser@sshhost $ ssh myuser@sshhost Password:<paste the copied password> myuser@sshhost:~$ </source>
Cooler way
Create an alias
<syntaxhighlight lang=bash> $ alias customerA-sshhost='sshpass -f <(pass Customers/CustomerA/sshuser@sshhost) ssh sshuser@sshhost' </source>
Use it
<syntaxhighlight lang=bash> $ customerA-sshhost sshuser@sshhost:~$ </source>
MySQL
Put only the password in your Customsers/CustomerB/mysqluser@mysqlhost:mysql.
Obvious way
<syntaxhighlight lang=bash> $ pass -c Customsers/CustomerB/mysqluser@mysqlhost:mysql $ mysql -h mysqlhost -u mysqluser Enter password: <paste the copied password> ... MariaDB [(none)]> </source>
Cooler way
Create an alias
<syntaxhighlight lang=bash> $ alias customerB-mysqlhost-mysqluser='mysql --user mysqluser --host mysqlhost --password=$(pass show Customsers/CustomerB/mysqluser@mysqlhost:mysql)' </source>
Or even cooler with seperate history and defaults file per connection <syntaxhighlight lang=bash> $ mkdir -p ~/Customsers/CustomerB/.mysql $ cat > ~/Customsers/CustomerB/.mysql/.my.cnf-mysqlhost-mysqluser << EOF [client] host=mysqlhost user=mysqluser EOF $ alias customerB-mysqlhost-mysqluser='MYSQL_HISTFILE=~/Customsers/CustomerB/.mysql/.mysql_history_mysqlhost mysql --defaults-file=~/Customsers/CustomerB/.mysql/.my.cnf-mysqlhost-mysqluser --password=$(pass show Customsers/CustomerB/mysqluser@mysqlhost:mysql)' </source>
Use it
<syntaxhighlight lang=bash> $ customerB-mysqlhost-mysqluser ... MariaDB [(none)]> </source>