KC(1)

NAME
kc - console based username and password management application

SYNOPSIS
kc [-k database file] [-r] [-p password file] [-m cipher mode] [-b] [-v] [-h]

DESCRIPTION
The kc utility is a console based username and password management application using an encrypted XML document as its database.

A database file can contain multiple keychains, and keychains in turn can contain multiple keys (usernames if you like) and values (passwords if you like).

After starting kc the help command shows the available commands, and usage information for them. If you're in a hurry, for starters, you create a new entry with the new command, then entering only a number in the command line will display the entry with the given index. You quit from the display with 'q' or EOT (usually CTRL+d).

The CLI supports tab-completion for commands and keychains.

There is a utility in the source package that converts an exported pwsafe database to a kc compatible XML database, which can be imported using the importxml command.

NOTE: Currently there is no character set conversion taking place in the program. In this case this means you must be ready to display anything you type in. If somehow you still end up with texts you can not display properly, and for whatever reason you can not edit them in kc, you can "repair" such database by dumping its content to a kc XML file (see the dump command below), converting the plain text XML file to a working character set, then importing back that XML file (see the importxml command below).

  PARAMETERS

-k file
    Use file as database. The default is ~/.kc/default.kcd.

-r  Open the database in read-only mode. kc will not try to lock the database file, and commands which could modify the database will not be available.

-p file
    Read password from file.

-m mode
    Cipher mode. mode can be one of 'cbc' (the default), 'cfb128' or 'ofb'. More information is in the CIPHERS section.

-b  Batch mode. Disable some features to enable commands from standard input.

-v  Display version.

-h  Display help.

  COMMANDS
These commands are available in the CLI:

new [name]
    Create a new key in the current keychain. Both key and value will be prompted for, except when name is specified; then it will be used as the key's name, up until the first space in name.

    Character sequences can be used in values:

    "\n" - create a new line, and make the result a multi-line value.

    "\r", "\R" - these will be replaced with 2 and 4 (respectively) random printable characters.

    "\a", "\A" - these will be replaced with 2 and 4 (respectively) random alpha-numeric characters.

    Character sequences are to be used in values, regardless of their order or count, and can be escaped using double backslashes (eg.: "\\a").

list [pager [offset]]
    List pager number of keys per page from the current keychain, skipping offset indices if specified. Every key gets prefixed by its index number. If pager is not specified, the default value of 20 is used. The special value 0 means to not use the pager. If offset is not specified, it is not used.

ls [pager [offset]]
    Alias of list.

edit index
    Edit a key. index is the key's index number in the current keychain.

    Character sequence rules in values apply to this command also. See command new for more information about this.

swap index index
    Swap two keys, exchanging their index numbers. The two index parameters are the keys' index numbers in the current keychain.

insert index index
    Move the key at the first index parameter to the index at the second index parameter in the current keychain. Surrounding indices will be shifted backwards or forwards.

search string
    Search for string in key names in the current keychain.

    Optional modifiers:

    ‘’! suffix (eg.: search!): show non-matching keys.

    ‘*’ suffix (eg.: search*): search in every keychain.

    ‘i’ suffix (eg.: searchi): case of characters doesn't matter.

    You can combine the modifiers.

/ pattern
    Search for pattern regular expression in key names in the current keychain.

    Optional modifiers:

    ‘’! suffix (eg.: /!): show non-matching keys.

    ‘*’ suffix (eg.: /*): search in every keychain.

    ‘i’ suffix (eg.: /i): case of characters doesn't matter.

    You can combine the modifiers.

csearch string
    Search for string in keychain names.

    Optional modifiers:

    ‘’! suffix (eg.: csearch!): show non-matching keychains.

    ‘i’ suffix (eg.: csearchi): case of characters doesn't matter.

    You can combine the modifiers.

c/ pattern
    Search for pattern regular expression in keychain names.

    Optional modifiers:

    ‘’! suffix (eg.: c/!): show non-matching keychains.

    ‘i’ suffix (eg.: c/i): case of characters doesn't matter.

    You can combine the modifiers.

c keychain
    Change the current keychain. keychain can be the keychain's index number or name. Index number takes priority when addressing a keychain.

cc keychain name
    Works like c, but the keychain's name takes priority over its index number. (see command c)

cdel keychain
    Delete a keychain. keychain can be the keychain's index number or name. Index number takes priority when addressing a keychain.

ccdel keychain name
    Works like cdel, but the keychain's name takes priority over its index number. (see command cdel)

clear [count]
    Emulate a screen clearing. Scrolls 50 lines by default, which can be multiplied by count times if specified.

clist
    List keychains. Every keychain gets prefixed by its index number.

cls Alias of clist.

cnew [name]
    Create a new keychain. If name is not given then prompt for one. Empty string cancels the addition.

cedit
    Edit the current keychain's name and description.

copy index keychain
    Copy a key from the current keychain to another keychain. index is the key's index number to copy and keychain is the destination keychain's index number or name. Index number takes priority when addressing a keychain.

cp index keychain
    Alias of copy.

move index keychain
    Move a key from the current keychain to another keychain. index is the key's index number to move and keychain is the destination keychain's index number or name. Index number takes priority when addressing a keychain.

mv index keychain
    Alias of move.

del index
    Delete a key. index is the key's index number in the current keychain.

rm index
    Alias of del.

passwd
    Change the database password. All changes will be written immediately.

help [command]
    Print application help or describe a command.

status
    Display information about the database.

xport filename [keychain]
    Export the database to a kc compatible encrypted database file named filename (if no extension specified, ".kcd" will be appended). When specifying a keychain, export only that keychain. keychain can be the keychain's index number or name. Index number takes priority when addressing a keychain. (see command dump, import and append)

dump filename [keychain]
    Dump the database to a kc compatible XML file named filename (if no extension specified, ".xml" will be appended). When specifying a keychain, dump only that keychain to the XML file. keychain can be the keychain's index number or name. Index number takes priority when addressing a keychain. (see command xport) NOTE: the created XML file will be plain text.

import filename
    Import and overwrite the current database with the one from a kc compatible encrypted database file named filename. filename must be a proper kc database. (see command importxml, xport and append)

importxml filename
    Import and overwrite the current database with the one from a kc compatible XML file named filename. filename must contain a properly formatted kc XML document. (see command import, xport and append)

append filename
    Append new and merge existing keychains to the database from a kc compatible encrypted database file named filename. filename must be a proper kc database. (see command appendxml, xport and import)

appendxml filename
    Append new and merge existing keychains to the database from a kc compatible XML file named filename. filename must contain a properly formatted kc XML document. (see command append, xport and import)

info [index]
    Print information about a key in the current keychain or the keychain itself. If index is specified, it is the key's index number in the current keychain. If omitted, information is about the current keychain.

quit
    Quit the program. If the database has been modified, then ask if it should be saved.

exit
    Alias of quit.

random [length]
    Print a random string with length length. The default length is 8.

version
    Display the program version.

write
    Save the database.

save
    Alias of write.

any number
    To display a key's value, you enter the key's index (ie.: only a number) into the command line, then it will display the entry with the given index. You quit from the display with 'q' or EOT (usually CTRL+d). By specifying another number after the index (eg.: '12 2' -- here 12 is the index, and 2 is the extra number (spice) after it), that many random characters will be displayed between the value's characters. You can navigate up/down through a multi-line value's lines with keys j/k, n/p, f/b, +/-, [/], {/}, </>, <SPACE>, <ENTER>, <BACKSPACE>. Typing a number between 1-9 will jump directly to that line.

    Perhaps the extra number (spice) after a key's index and its usefulness can use some further explanation. Let's say you want to display a password to use it on a website's form, but you don't want the people walking by or around you to recognize words, numbers or parts of it. You can use this nifty "trick" to tell kc to display that many random characters between the value's original characters when showing it to you. Granted, it will look like a mess (although, that is what we wanted), but you can copy-paste it to the password entry in the website form in question. Then you can start to "blindly" delete the given number of characters from it by moving you cursor to the beginning (eg. HOME key), pressing 'spice' numbers of DEL, then jump over one character to the right (with the right arrow key), then delete the random characters again, then repeating this until you reach the end of you original password (those who played Mortal Kombat will feel a bit nostalgic). You can catch on to this, because the random character padding is of fixed length, so the pattern remains the same for the whole password. You don't even have to pay attention to the original length of the password, because after you've completed the pattern (DELs-move-DELs-move...) and removed the spice (ie.: every padding random character), you end up with you original password, and you'll just be deleting nothing after the end of the string. This of course only makes sense if the form is a password input field, so you (and everybody else) just see stars or dots in place of the password.

  CIPHERS
All ciphers use 128 bit keys, generated with a KDF (key-derivation function) from the supplied password, an IV (initialization vector) and a salt. Both the IV and the salt are 128 bits long and read from the host's specific random device ( /dev/urandom on Linux and /dev/random on everything else ).

EXAMPLES

pwsafe_to_kc.pl:

        # Export the pwsafe database to a cleartext file:
        $ pwsafe --exportdb > pwsafe_export
        Enter passphrase for .pwsafe.dat:
        # Convert the cleartext pwsafe database to a kc XML database file:
        $ pwsafe_to_kc.pl pwsafe_export kc_db.xml
        opening pwsafe_export for reading.
        opening kc_db.xml for writing.
        Converting...
        Done.

    After the above commands, you should end up with a kc compatible XML database. You can import it to kc using the importxml command.

Adding new entries:

        Simple:
        default% > new testuser
        default% NEW value> testpass
        Prompt for both key and value:
        default% > new
        default% NEW key> testuser2
        default% NEW value> test_\r_pass_with_random_characters:\A
        Using the 'key' only as an indication:
        default% > new www.mysecuresite.com
        default% NEW value> user_name\npass-word
        Using the random and newline character sequences:
        default% > new testuser3
        default% NEW value> \r\R\n\a\A\nthis is a multi-line value!
        Creating new keychains:
        default% > cnew email_accounts
        default% > cnew
        default% NEW keychain name> WebSite Accounts
        default% NEW keychain description> description
        Results:
        Listing the keys in the current keychain:
        default% > list
        0. testuser
        1. testuser2
        2. www.mysecuresite.com
        3. testuser3
        Displaying values in the current keychain:
        default% > 0
        [testuser] testpass
        default% > 1
        [testuser2] test_,x_pass_with_random_characters:6nzm
        default% > 2
        [www.mysecuresite.com] [1/2] user_name
        [www.mysecuresite.com] [2/2] pass-word
        default% > 3
        [testuser3] [1/3] v#)z!9
        [testuser3] [2/3] HwRz7i
        [testuser3] [3/3] this is a multi-line value!
        Listing keychains:
        default% > clist
        0. default
        1. email_accounts
        2. WebSite Accounts
        Switch to another keychains:
        default% > c email_accounts
        email_accounts% > c 2
        WebSite Accounts% >

Editing existing entries:

        default% > list
        0. testuser
        1. testuser2
        2. www.mysecuresite.com
        3. testuser3
        Edit an entry in the current keychain:
        default% > edit 1
        default% EDIT key> testuser2
        default% EDIT value> test_pass_with_random_characters:6nzm
        default% > 1
        [testuser2] test_pass_with_random_characters:6nzm
        Rename a keychain:
        default% > cedit default
        default% EDIT keychain name> my_own keychain
        default% EDIT keychain description> description
        my_own keychain% >

CAVEATS
If you use 'cfb128' or 'ofb' for cipher, there is no specific sign if you enter a wrong password during the opening of a database; in this case the database would seem to be corrupt after decrypting, and kc will not be able to open it.

If you use xport to export to an encrypted kc database, it is not possible to choose a different cipher mode than the one being used with the current database. It is also not possible to choose a cipher mode during an import of an encrypted kc database, and the one being utilized by the current database will be used.

There is no character conversion taking place for the input fields.

AUTHOR
kc was written by LEVAI Daniel <leva@ecentrum.hu>

Source, information, bugs: http://keychain.googlecode.com