How to Configure Dify SSH Credentials

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up dify ssh credentials by adding a private key to your workflow tool. The remote server then checks the matching public key when your agent logs in. Teams often create one shared key for all their automated AI workflows. They place this key on every host the agent needs to reach. When that shared role has broad shell rights, one bad prompt can cause harm. An agent might run a destructive command or read sensitive files by mistake. How to set up dify ssh credentials A Dify workflow us

Ephemeral Credentials + SSH Access Management: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up dify ssh credentials by adding a private key to your workflow tool. The remote server then checks the matching public key when your agent logs in. Teams often create one shared key for all their automated AI workflows. They place this key on every host the agent needs to reach. When that shared role has broad shell rights, one bad prompt can cause harm. An agent might run a destructive command or read sensitive files by mistake.

How to set up dify ssh credentials

A Dify workflow uses custom tools or code blocks to reach outside systems. To run commands on a Linux host, the tool needs an SSH key pair. You generate a private key and store it inside the Dify secret store. Then you place the public key on the target server for a specific user.

Instead of static keys, many teams use OpenSSH certificates for safer logins. OpenSSH added certificate support for users and hosts in version 5.4. The key tool signs a public key with a Certificate Authority key. This signed certificate holds the public key, identity info, and allowed user names. It also holds a set of options, and uses a simpler format than X.509.

When you sign a user certificate, you set an identity string and principal names. You can also set a time window so the key expires on schedule. If you skip the time window, the certificate stays valid forever by default. Using short validity windows stops old agent keys from working after a task ends.

Why static host keys fall short for AI agents

Native SSH keys and certificates do a great job of checking who logs in. They prove that the Dify workflow holds a valid key signed by your authority. They also map that login to a local Linux user on the host.

Still, login checks do not control what happens after the shell session starts. Once the agent logs in, it inherits the full rights of that Linux user. Native SSH setup decides who enters the server, not what each command does. If an AI agent hallucinates a command, the host runs it right away.

Ephemeral Credentials + SSH Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Standard server logs only show that the shared agent user logged into the box. They rarely tie each shell command back to the person who ran the workflow. Also, command outputs can return sensitive data like emails, phone numbers, or card numbers. Native SSH returns that raw text straight into the model context without rewriting fields.

Scoping agent commands on target hosts

You can limit damage by creating a strict Linux user just for Dify tasks. Give that user read rights only on the folders the workflow must check. Never give the workflow user full root rights on a production machine.

You should also attach options when you sign an OpenSSH user certificate. Certificate options can restrict which features the session can use on the host. Even with these host rules, managing local users across many servers takes heavy work. Teams need a simpler way to inspect commands and mask data in flight.

Add command and file guardrails to SSH access

Host firewalls and certificate principals control who opens an SSH session. Yet an allowed user or agent can still run a bad one-shot command or pull sensitive files over sftp. In practice, hoop.dev provides an open-source SSH server with guardrails on the host that uses OpenSSH certificates.

Using hoop.dev SSH controls, guardrails check one-shot commands, env variable names, and sftp or scp paths before they run. Port forwards default to deny unless the target is listed. Because interactive shells have no statement boundary and carry no guardrails, teams can turn them off so every command is checked and logged. Check out the MIT-licensed project on GitHub.

Frequently asked questions

How should teams store dify ssh credentials safely?

Store private keys as encrypted variables inside your workflow secret store, not in plain text. Rotate these keys often or switch to short-lived OpenSSH user certificates instead.

Why are OpenSSH certificates better than static keys for AI workflows?

Static keys work forever until someone removes them from the target server. OpenSSH certificates let you sign a public key with a strict expiration window.

What is the main risk of giving an AI workflow SSH access?

An AI model can misread a prompt and run harmful shell commands fast. It can also pull raw emails or national IDs from server logs into prompts.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.