Tech
Infected

Linux, OpenSource, Programming And Hacks

May 19, 2016

Best command-line Password Manager for Linux/ubuntu - kpcli

May 19, 2016


kpcli is a command line password manager for linux/unix. We can store login credential of various accounts in a databases and access the database with a master password. All kpcli commands  are almost same as linux commands, so it will be nice if you are familiar with them already. kpcli database file can work with keepassx (gui) and vice versa.

Let's quickly go through this tutorial to see how to install and use it.

Install in Ubuntu/Linux Mint/Debian

sudo apt-get install kpcli

1. Launch kpcli

To start kpcli after it has installed just enter kpcli.
you will get a kpcli prompt after entering the command.
aman@vostro:~$ kpcli

KeePass CLI (kpcli) v2.7 is ready for operation.
Type 'help' for a description of available commands.
Type 'help ' for details on individual commands.

kpcli:/> 

2. Create a Password Database.

Lets create a password database by entering the following command. we will store all our passwords in this database. you are asked to give a master password. Make sure you remember it always.
kpcli:/> saveas mypasswords.kdb
Please provide the master password: *************************
Retype to verify: *************************

3. Create  directories to categorize accounts.

Lets create a folder named social, where we will keep all our social network accounts passwords.

kpcli:/> mkdir social
Now, lets view if our directory got created with the ls command
kpcli:/> ls
=== Groups ===
eMail/
Internet/
social/
eMail and Internet are present by default.

4. Create Account Password Entries.

Lets first use the cd command to change to our social directory that we just created
cd social
and then enter the new command to make a entry.
kpcli:/social> new
Adding new entry to "/social"
Title: Twitter
Username: TechInfected
Password:                ("g" or "w" to auto-generate, "i" for interactive)
Retype to verify: 
URL: twitter.com
Notes/Comments (""): 
(end multi-line input with a single "." on a line)
| .
Database was modified. Do you want to save it now? [y/N]: 
Saved to mypasswords.kdb

you can hit "g" for creating a strong password automatically. you wont be shown the password but it will generate it in background.

you can enter comments like password hint or something and end it with a dot, or just dot it you don't want to enter any comments like I did.


Let's view our newly added entry with the ls command.
kpcli:/social> ls
=== Entries ===
0. Twitter                                                     twitter.com
Lets add one more entry for facebook account.
kpcli:/social> new
Adding new entry to "/social"
Title: Facebook
Username: TechInfected
Password:                ("g" or "w" to auto-generate, "i" for interactive)
Retype to verify: 
URL: facebook.com
Notes/Comments (""): 
(end multi-line input with a single "." on a line)
| .
Database was modified. Do you want to save it now? [y/N]: 
Saved to mypasswords.kdb

5. View the saved password from entries.

First, list the entries.
kpcli:/social> ls
=== Entries ===
0. Facebook                                                   facebook.com
1. Twitter                                                     twitter.com

Let's view the Twitter account details using the show command followed by -f option and the entry number which is 0 for Facebook and 1 for twitter.
kpcli:/social> show -f 0

Path: /social
Title: Facebook
Uname: TechInfected
 Pass: abc
  URL: facebook.com
Notes: 

There you can see the password 'abc'. Never set such a silly password ;)

6. Edit an Entry 
use the edit command to change the Title, username, password, or comment.
kpcli:/social> ls
=== Entries ===
0. Facebook                                                   facebook.com
1. Google Plus                                             plus.google.com
2. Twitter                                                     twitter.com
kpcli:/social> edit 0
Title: Facebook
Username: TechInfected
Password:                ("g" or "w" to auto-generate, "i" for interactive)
URL: facebook.com
Notes/Comments (""): 
(end multi-line input with a single "." on a line)
| hello
| .
Database was modified. Do you want to save it now? [y/N]: 

here, I just added a comment 'hello' and left everything unchanged.

7. Search for an Entry

kpcli:/> find twitter
Searching for "twitter" ...
 - 1 matches found and placed into /_found/
Would you like to show this entry? [y/N] 

 Path: /social/
Title: Twitter
Uname: TechInfected
 Pass: abc123
  URL: twitter.com
Notes: 

8. Exit kpcli 

Simply use quit command or hit Ctrl+d and you will come back to your $ prompt.
kpcli:/social> quit
aman@vostro:~$ 

9. Reopen the password database.

Enter this command to open kpcli with the password database that we just created.
aman@vostro:~$ kpcli --kdb mypasswords.kdb 
Please provide the master password: *************************

KeePass CLI (kpcli) v2.7 is ready for operation.
Type 'help' for a description of available commands.
Type 'help ' for details on individual commands.

kpcli:/> 

10. View all kpcli commands

Run kpcli with no options and enter help to learn all kpcli commands.

kpcli:/> help
  attach -- Manage attachments: attach 
      cd -- Change directory (path to a group)
      cl -- Change directory and list entries (cd+ls)
   clone -- Clone an entry: clone  
   close -- Close the currently opened database
     cls -- Clear screen ("clear" command also works)
    copy -- Copy an entry: copy  
    edit -- Edit an entry: edit 
  export -- Export entries to a new KeePass DB (export  [])
    find -- Finds entries by Title
    help -- Print helpful information
 history -- Prints the command history
   icons -- Change group or entry icons in the database
  import -- Import another KeePass DB (import   [])
      ls -- Lists items in the pwd or a specified path ("dir" also works)
   mkdir -- Create a new group (mkdir )
      mv -- Move an item: mv  
     new -- Create a new entry: new 
    open -- Open a KeePass database file (open  [])
    pwck -- Check password quality: pwck 
     pwd -- Print the current working directory
    quit -- Quit this program (EOF and exit also work)
  rename -- Rename a group: rename 
      rm -- Remove an entry: rm 
   rmdir -- Delete a group (rmdir )
    save -- Save the database to disk
  saveas -- Save to a specific filename (saveas  [])
    show -- Show an entry: show [-f] [-a] 
   stats -- Prints statistics about the open KeePass file
     ver -- Print the version of this program
    vers -- Same as "ver -v"
      xp -- Copy password to clipboard: xp 
      xu -- Copy username to clipboard: xu 
      xw -- Copy URL (www) to clipboard: xw 
      xx -- Clear the clipboard: xx

Type "help " for more detailed help on a command.



No comments:

Post a Comment