Pass: Difference between revisions

From Lolly's Wiki
Jump to navigationJump to search
m (Text replacement - "<source" to "<syntaxhighlight")
m (Text replacement - "</source" to "</syntaxhighlight")
Line 15: Line 15:
Password:<paste the copied password>
Password:<paste the copied password>
myuser@sshhost:~$  
myuser@sshhost:~$  
</source>
</syntaxhighlight>


====Cooler way====
====Cooler way====
Line 22: Line 22:
<syntaxhighlight lang=bash>
<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>
</syntaxhighlight>


=====Use it=====
=====Use it=====
Line 28: Line 28:
$ customerA-sshhost
$ customerA-sshhost
sshuser@sshhost:~$  
sshuser@sshhost:~$  
</source>
</syntaxhighlight>


===MySQL===
===MySQL===
Line 40: Line 40:
...
...
MariaDB [(none)]>
MariaDB [(none)]>
</source>
</syntaxhighlight>


====Cooler way====
====Cooler way====
Line 47: Line 47:
<syntaxhighlight lang=bash>
<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>
</syntaxhighlight>


Or even cooler with seperate history and defaults file per connection
Or even cooler with seperate history and defaults file per connection
Line 58: Line 58:
EOF
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)'
$ 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>
</syntaxhighlight>


=====Use it=====
=====Use it=====
Line 65: Line 65:
...
...
MariaDB [(none)]>
MariaDB [(none)]>
</source>
</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]

Revision as of 16:28, 25 November 2021

pass

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