Skip to content

Repository files navigation

docker-ssh

Note

This code was generated with the assistance of a generative AI system (OpenCode / large language model). Please review and test it before using it in production.

docker-ssh is a Docker CLI plugin that connects to a remote server via SSH using the host configured in a Docker context. If a context's Docker endpoint is ssh://user@host:port, running docker ssh <context> opens an SSH session to that host.

Repository: https://github.com/saitho/docker-ssh

Requirements

  • Docker CLI (the plugin uses docker context inspect to read context data)
  • OpenSSH client (ssh must be in your PATH)
  • Go 1.21+ (only for building from source)

Installation

From source

git clone https://github.com/saitho/docker-ssh.git
cd docker-ssh
make build
make install

This places the docker-ssh binary in ~/.docker/cli-plugins/, which is the standard Docker CLI plugin directory.

Manual install

Download or build the docker-ssh binary, make it executable, and put it in a location Docker searches for plugins:

mkdir -p ~/.docker/cli-plugins
cp docker-ssh ~/.docker/cli-plugins/
chmod +x ~/.docker/cli-plugins/docker-ssh

You can also place it anywhere in your PATH with the exact name docker-ssh.

Verify

docker ssh --help

Usage

Connect to the SSH host defined by a context:

docker context create --docker host=ssh://user@remote:22 mycontext
docker ssh mycontext

Run a command on the remote host:

docker ssh mycontext ls -la
docker ssh mycontext -- ls -la

Common SSH options are supported as flags:

docker ssh -A mycontext
docker ssh -i ~/.ssh/id_rsa -p 2222 mycontext
docker ssh -L 8080:localhost:80 mycontext
docker ssh -J jump-host mycontext

Additional options that do not have a dedicated flag can be passed with --ssh-arg:

docker ssh mycontext --ssh-arg=-o --ssh-arg=StrictHostKeyChecking=no

Everything after the context name is forwarded to the remote host as a command.

Uninstall

rm ~/.docker/cli-plugins/docker-ssh

AI-generated content notice

This project was created with the assistance of generative AI. While the generated code has been reviewed and tested to the extent possible, you should inspect it before deploying it in production environments.

About

Opens SSH connection to target servers defined in Docker context

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages