=encoding UTF-8 =head1 Name sqitch-passwords - Guide to using database passwords with Sqitch =head1 Description You may have noticed that Sqitch has no C<--password> option. This is intentional. It's generally not a great idea to specify a password on the command-line: from there, it gets logged to your command history and is easy to extract by anyone with access to your system. So you might wonder how to specify passwords so that Sqitch an successfully deploy to databases that require passwords. There are three recommended approaches, in order from most- to least-recommended: =over =item 1. Avoid using a password at all =item 2. Use a database engine-specific password file =item 3. Use the C<$SQITCH_PASSWORD> environment variable =item 4. Include the password in the deploy target URI =back Each is covered in detail in the sections below. =head1 Don't use Passwords Of course, the best way to protect your passwords is not to use them at all. If your database engine is able to do passwordless authentication, it's worth taking the time to make it work, especially on your production database systems. Some examples: =over =item PostgreSQL PostgreSQL supports a number of L, including the passwordless L, L, and, for local connections, L. =item MySQL MySQL supports a number of L, plus L. =item Oracle Oracle supports a number of L, including L, L, and, for local connections, L. =item Vertica Vertica supports a number of L including the passwordless L, L, and, for local connections, L. =item Firebird Firebird supports passwordless authentication only via L for local connections. =back =head1 Use a Password File If you must use password authentication with your database server, you may be able to use a protected password file. This is file with access limited only to the current user that the server client library can read in. As such, the format is specified by the database vendor, and not all database servers offer the feature. Here's how the database engines supported by Sqitch shake out: =over =item PostgreSQL PostgreSQL will use a L file|http://www.postgresql.org/docs/current/static/libpq-pgpass.html> in the user's home directory to or referenced by the C<$PGPASSFILE> environment variable. This file must limit access only to the current user (C<0600>) and contains lines specify authentication rules as follows: hostname:port:database:username:password =item MySQL For MySQL, passwords can be specified in the L and F<~/.my.cnf> files|http://dev.mysql.com/doc/refman/5.1/en/password-security-user.html#idm139947650158560>. These files must limit access only to the current user (C<0600>) and. Sqitch will look for a password under the C<[client]> and C<[mysql]> sections, in that order. =item Oracle Oracle supports C created with the C utility to authenticate C and C users, but B Neither can one L into a L|http://docs.oracle.com/cd/B28359_01/network.111/b28317/tnsnames.htm#NETRF007> file. =item Vertica Vertica does not currently support a password file. =item Firebird Firebird does not currently support a password file. =back =head1 Use C<$SQITCH_PASSWORD> The C<$SQITCH_PASSWORD> environment variable can be used to specify the password for any supported database engine. However use of this environment variable is not recommended for security reasons, as some operating systems allow non-root users to see process environment variables via C. The behavior of C<$SQITCH_PASSWORD> is consistent across all supported engines. Some database engines support their own password environment variables, which you may wish to use instead. However, their behaviors may not be consistent: =over =item PostgreSQL C<$PGPASSWORD> =item MySQL C<$MYSQL_PWD> =item Vertica C<$VSQL_PASSWORD> =item Firebird C<$ISC_PASSWORD> =back =head1 Use Target URIs Passwords may also be specified in L. This is not generally recommended, since such URIs are either specified via the command-line (and therefore visible in C and your shell history) or stored in the L, the project instance of which is generally pushed to your source code repository. But it's provided here as an absolute last resort (and because web URLs support it, though it's heavily frowned upon there, too). Such URIs can either be specified on the command-line: sqitch deploy db:pg://fred:s3cr3t@db.example.com/widgets Or stored as named targets in the project configuration file: sqitch target add wigets db:pg://fred:s3cr3t@db.example.com/widgets After which the target is available by its name: sqitch deploy widgets See L and C for details on target configuration. =head1 See Also =over =item * L =item * L =item * L =back =head1 Sqitch Part of the L suite.