OpenPubKey SSH
Sign in to SSH servers with OpenPubKey SSH (opkssh) and Pocket ID.
This guide assumes OpenPubKey SSH (opkssh) is installed on both the server and the client. For installation instructions for different operating systems, see https://github.com/openpubkey/opkssh.
Create the client in Pocket ID
Section titled “Create the client in Pocket ID”- In Pocket ID, open Administration → OIDC Clients and click Add OIDC Client.
- Enter a name such as
OpenPubKey SSH, choose Public Client as the client type and add the callback URLs:http://localhost:3000/login-callbackhttp://localhost:10001/login-callbackhttp://localhost:11110/login-callback - Click Create and copy the Client ID.
- On the client’s Access tab, select the groups that may sign in under Allowed User Groups, or choose All Users.
Collect user and audience information
Section titled “Collect user and audience information”- Open the client in Pocket ID and click OIDC Data Preview at the top of the page.
- Select the user and copy the
audandsubvalues.
Configure the provider on the server
Section titled “Configure the provider on the server”- Sign in to the server running SSH. Ubuntu is used in this example, but other Linux distributions, Windows Server and Windows 11 are supported as well.
- Edit the providers file, located at
/etc/opk/providersby default on Linux. - Add the following line to the bottom of the file:
https://id.example.com <AUD_GUID> 24h
- Replace
<AUD_GUID>with theaudvalue you copied above. 24his the token lifetime. You can change it to a different value, such as12hor6h.
- Replace
- Remove the default providers from the file if you don’t need them, and save it.
Map users and groups on the server
Section titled “Map users and groups on the server”- Map OIDC users and groups to a local user by running the following command on the server:
Terminal window opkssh add <user> <email/sub/group> <issuer> - User example (replace
<SUB_GUID>with thesubvalue you copied above):Terminal window opkssh add root <SUB_GUID> https://id.example.com - Group example (assumes there is a Pocket ID group named
opkssh_users):Pocket ID only sends the groups claim when theTerminal window opkssh add root oidc:groups:opkssh_users https://id.example.comgroupsscope is requested, so the client configuration below includes it.
Configure the client
Section titled “Configure the client”- In a terminal on the client, run the following command:
This creates the file
Terminal window opkssh login --create-config~/.opk/config.ymlin your home folder. - Add the following to the end of the file and replace
<client-id>with the Client ID from Pocket ID:- alias: pocket-idissuer: https://id.example.comclient_id: <client-id>scopes: openid email groupsaccess_type: offlineprompt: consentredirect_uris:- http://localhost:3000/login-callback- http://localhost:10001/login-callback- http://localhost:11110/login-callback - Remove the other providers if you don’t need them and save the file.
Sign in
Section titled “Sign in”- On the client, run the following command:
This opens the Pocket ID sign-in page in your default browser.
Terminal window opkssh login pocket-id - After signing in, you can close the page.
- Back in the terminal, run
ssh user@server, whereuseris the mapped local user andserveris the server running opkssh. You’re signed in to the server automatically.
You can also run opkssh login without the alias.
This opens a page in your browser with a list of the configured providers, where you choose Pocket ID.
You can configure multiple servers to use the same Pocket ID client for opkssh. If you want to limit different Pocket ID users to different servers, you need multiple clients.