Remote Deploy & SSH Agent Cache

SKM goes beyond local file management by wrapping standard OpenSSH utilities to help you deploy keys to remote servers and manage passphrases effectively.

Deploying Keys with skm copy

The copy (or cp) command is a frictionless wrapper around the standard ssh-copy-id tool. Its purpose is to take the currently active SKM public key and append it to the ~/.ssh/authorized_keys file of a remote server.

Why use skm copy over native ssh-copy-id? Native ssh-copy-id can behave unpredictably if you have multiple keys floating around, sometimes attempting to push all of them. SKM strictly limits the payload to the single identity you currently have active in ~/.ssh.

Usage:

skm copy [options] user@host

Options:

  • -p <port>: Specify a non-standard SSH port on the remote host.

Real-World Workflow:

  1. Ensure you have the right key active:

    skm use target-server-key

  2. Push the key to the server (you will be prompted for the user's password on the remote machine):

    skm copy -p 2222 [email protected]

  3. Test the connection. You should now be logged in via SSH key authentication rather than a password.

Requirement: The ssh-copy-id binary must be installed on your local machine. This is standard on macOS and most Linux distros, but Windows users may need to ensure it is bundled with their SSH client setup.


Managing Passphrases with skm cache

If you secure your SSH private keys with a passphrase (which is highly recommended for security), typing that passphrase every time you perform a git push or SSH into a server is tedious.

The ssh-agent solves this by keeping your decrypted keys in memory. The skm cache command provides a clean interface to add and remove specific SKM aliases from the active ssh-agent.

Usage:

skm cache [flags] <alias>

Adding a key to the cache

To load an identity into the agent, use the --add flag:

skm cache --add github-work
You will be prompted by ssh-add to enter your passphrase. Once entered, the key remains decrypted in memory for the duration of the agent's lifecycle.

Removing a key from the cache

If you are leaving your computer or switching contexts, you can explicitly purge an identity from the agent memory using the --del flag:

skm cache --del github-work

Listing cached keys

To view all identities currently held in memory by ssh-agent, use the --list flag. (The <alias> argument is ignored for this command):

skm cache --list

Output Example:

2048 SHA256:qAVcwc0tdUOCjH3sTskwxAmfMQiL2sKtfPBXFnUoZHQ /Users/user/.skm/github-work/id_rsa (RSA)

Troubleshooting the Cache

If skm cache commands fail with errors like "Could not open a connection to your authentication agent", it means the OS-level ssh-agent is not running in your current terminal session.

To fix this on Linux or macOS, evaluate the agent startup command in your shell before running SKM:

eval "$(ssh-agent -s)"
skm cache --add my-alias