Skip to content

Secure Connections for ybsql (libpq)

Assuming you are using the default locations, you can test the basic connection by using a ybsql login command like this:

ybsql "sslmode=<ssl_mode> host=<hostname> dbname=<dbname> user=<username>"

For example, from a Linux command prompt:

% ybsql "sslmode=prefer host=***********.yellowbrickcloud.com dbname=yellowbrick user=ybdadmin@yellowbrickcloud.com"
Password: 
ybsql (6.1.0)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type:  \h for help with SQL commands
      \? for help with ybsql commands
      \g or terminate with semicolon to execute query
      \q to quit
yellowbrick=>

You will be prompted for your password and a secure connection is attempted.

Example: ybsql on Windows (verify-ca, using a non-default root cert)

You can precede the libpq connection string with options such as -c to execute a command. For example, this connection runs a query against the sys.session view and returns the secure details for the session:

ybsql -c "select secure_details from sys.session where process_id = pg_backend_pid()" 
"sslmode=verify-ca sslrootcert=/ybd/star.nyc.yellowbrick.io.pem host=yb007.nyc.yellowbrick.io dbname=yellowbrick user=yellowbrick"
...
secure_details
----------------------------------------------
TLSv1.2/ECDHE-RSA-AES256-GCM-SHA384/256 bits
(1 row)

Parent topic:Secure Connections for ODBC/JDBC Clients and ybsql