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…“)
 
m (Text replacement - "[[Kategorie:" to "[[Category:")
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:Linux|pass]]
=pass - The standard unix password manager=
=pass - The standard unix password manager=


Line 6: Line 7:


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====
<source lang=bash>
<syntaxhighlight lang=bash>
$ pass -c Customers/CustomerA/myuser@sshhost
$ pass -c Customers/CustomerA/myuser@sshhost
$ ssh myuser@sshhost
$ ssh myuser@sshhost
Password:<paste the copied password>
Password:<paste the copied password>
myuser@sshhost:~$  
myuser@sshhost:~$  
</source>
</syntaxhighlight>


====Cooler way====
====Cooler way====


=====Create the password entry=====
=====Create an alias=====
Put only the password at the first line (needed for sshpass).
<syntaxhighlight lang=bash>
<source lang=bash>
$ alias customerA-sshhost='sshpass -f <(pass Customers/CustomerA/sshuser@sshhost) ssh sshuser@sshhost'
$ pass edit Customers/CustomerA/myuser@sshhost
</syntaxhighlight>
</source>
 
=====Use it=====
<syntaxhighlight lang=bash>
$ customerA-sshhost
sshuser@sshhost:~$
</syntaxhighlight>
 
===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)]>
</syntaxhighlight>
 
====Cooler way====


=====Create an alias=====
=====Create an alias=====
<source lang=bash>
<syntaxhighlight 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>
</syntaxhighlight>
 
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)'
</syntaxhighlight>


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


==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]

Latest revision as of 01:54, 26 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

$ 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