Pass: Difference between revisions

From Lolly's Wiki
Jump to navigationJump to search
(Die Seite wurde neu angelegt: „=pass - The standard unix password manager= ==Tipps & Tricks== ===SSH=== To pass the password to the ssh password promt you need another tool, too: sshpass…“)
 
Line 6: Line 6:


To pass the password to the ssh password promt you need another tool, too: sshpass .
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====
====Obvious way====
Line 17: Line 18:
====Cooler way====
====Cooler way====


=====Create the password entry=====
=====Create an alias=====
Put only the password at the first line (needed for sshpass).
<source lang=bash>
<source lang=bash>
$ pass edit Customers/CustomerA/myuser@sshhost
$ alias customerA-sshhost='sshpass -f <(pass Customers/CustomerA/sshuser@sshhost) ssh sshuser@sshhost'
</source>
</source>
=====Use it=====
<source lang=bash>
$ customerA-sshhost
sshuser@sshhost:~$
</source>
===MySQL===
Put only the password in your Customsers/CustomerB/mysqluser@mysqlhost:mysql.
====Obvious way====
<source 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=====
=====Create an alias=====
<source lang=bash>
<source lang=bash>
$ alias customer-sshhost='sshpass -f <(pass Customers/CustomerA/myuser@sshhost) ssh myuser@sshhost'
$ 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
<source 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>
</source>


=====Use it=====
=====Use it=====
<source lang=bash>
<source lang=bash>
$ customer-sshhost
$ customerB-mysqlhost-mysqluser
myuser@sshhost:~$
...
MariaDB [(none)]>
</source>
</source>


==Links==
==Links==
* [https://www.passwordstore.org/ Official site of pass]
* [https://www.passwordstore.org/ Official site of pass]
* [https://sourceforge.net/projects/sshpass/ sshpass]
* [https://sourceforge.net/projects/sshpass/ sshpass]

Revision as of 16:21, 18 September 2019

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

$ pass -c Customers/CustomerA/myuser@sshhost
$ ssh myuser@sshhost
Password:<paste the copied password>
myuser@sshhost:~$

Cooler way

Create an alias
$ alias customerA-sshhost='sshpass -f <(pass Customers/CustomerA/sshuser@sshhost) ssh sshuser@sshhost'
Use it
$ customerA-sshhost
sshuser@sshhost:~$

MySQL

Put only the password in your Customsers/CustomerB/mysqluser@mysqlhost:mysql.

Obvious way

$ pass -c Customsers/CustomerB/mysqluser@mysqlhost:mysql
$ mysql -h mysqlhost -u mysqluser
Enter password: <paste the copied password>
...
MariaDB [(none)]>

Cooler way

Create an alias
$ alias customerB-mysqlhost-mysqluser='mysql --user mysqluser --host mysqlhost --password=$(pass show Customsers/CustomerB/mysqluser@mysqlhost:mysql)'

Or even cooler with seperate history and defaults file per connection

$ 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)'
Use it
$ customerB-mysqlhost-mysqluser
...
MariaDB [(none)]>

Links