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
- Docker CLI (the plugin uses
docker context inspectto read context data) - OpenSSH client (
sshmust be in yourPATH) - Go 1.21+ (only for building from source)
git clone https://github.com/saitho/docker-ssh.git
cd docker-ssh
make build
make installThis places the docker-ssh binary in ~/.docker/cli-plugins/, which is the standard Docker CLI plugin directory.
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-sshYou can also place it anywhere in your PATH with the exact name docker-ssh.
docker ssh --helpConnect to the SSH host defined by a context:
docker context create --docker host=ssh://user@remote:22 mycontext
docker ssh mycontextRun a command on the remote host:
docker ssh mycontext ls -la
docker ssh mycontext -- ls -laCommon 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 mycontextAdditional options that do not have a dedicated flag can be passed with --ssh-arg:
docker ssh mycontext --ssh-arg=-o --ssh-arg=StrictHostKeyChecking=noEverything after the context name is forwarded to the remote host as a command.
rm ~/.docker/cli-plugins/docker-sshThis 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.