{"id":13521921,"url":"https://github.com/yokawasa/kubectl-plugin-ssh-jump","last_synced_at":"2025-08-20T01:31:18.583Z","repository":{"id":44248185,"uuid":"167761778","full_name":"yokawasa/kubectl-plugin-ssh-jump","owner":"yokawasa","description":"A kubectl plugin to access nodes or remote services using a SSH jump Pod","archived":false,"fork":false,"pushed_at":"2024-02-15T09:53:00.000Z","size":464,"stargazers_count":177,"open_issues_count":1,"forks_count":18,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-12-18T23:34:25.160Z","etag":null,"topics":["kubectl","kubectl-plugin","kubectl-plugins","kubernetes","ssh","ssh-agent"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yokawasa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-27T02:34:35.000Z","updated_at":"2024-12-06T13:40:02.000Z","dependencies_parsed_at":"2024-01-13T22:23:34.758Z","dependency_job_id":"3097585b-3b70-45f8-b4e9-c8a31e4d94db","html_url":"https://github.com/yokawasa/kubectl-plugin-ssh-jump","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokawasa%2Fkubectl-plugin-ssh-jump","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokawasa%2Fkubectl-plugin-ssh-jump/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokawasa%2Fkubectl-plugin-ssh-jump/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yokawasa%2Fkubectl-plugin-ssh-jump/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yokawasa","download_url":"https://codeload.github.com/yokawasa/kubectl-plugin-ssh-jump/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230382858,"owners_count":18216854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kubectl","kubectl-plugin","kubectl-plugins","kubernetes","ssh","ssh-agent"],"created_at":"2024-08-01T06:00:39.605Z","updated_at":"2024-12-19T05:07:23.501Z","avatar_url":"https://github.com/yokawasa.png","language":"Shell","funding_links":[],"categories":["kubectl Plugins"],"sub_categories":["Installing plugins via awesome-kubectl-plugins"],"readme":"# kubectl-plugin-ssh-jump\n\n[![kubectl plugin](https://img.shields.io/badge/kubectl-plugin-blue.svg)](https://github.com/topics/kubectl-plugin)\n\nA kubectl plugin to access Kubernetes nodes or remote services using a SSH jump Pod\n\nA `jump host` Pod is an intermediary Pod or an SSH gateway to Kubernetes node machines, through which a connection can be made to the node machines or remote services.\n\nHere is an scenario where you want to connect to Kubernetes nodes or remote services, but you have to go through a jump host Pod, because of firewalling, access privileges. etc. There is a number of valid reasons why the jump hosts are needed...\n\n**CASE 1: SSH into Kubernetes nodes via SSH jump Pod**\n![](assets/ssh-jump-node-ssh-login.png)\n\n**CASE 2: Connect to remote serivces via SSH local port forwarding**. SSH local port forwarding allows to forward the traffic form local machine to SSH jump then SSH jump will forward the traffic to remote services (host:port)s. \n![](assets/ssh-jump-ssh-tunnel.png)\n\n\u003e [NOTE]\n\u003e - Kubectl versions \u003e= `1.12.0` (Preferred)\n\u003e   - As of Kubernetes 1.12, kubectl now allows adding external executables as subcommands. For more detail, see [Extend kubectl with plugins](https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/)\n\u003e   - You can run the plugin with `kubectl ssh-jump ...`\n\u003e - Kubectl versions \u003c `1.12.0`\n\u003e   - You still can run the plugin directly with `kubectl-ssh-jump ...`\n\n\n**Table of Content**\n\u003c!-- TOC --\u003e\n\n- [kubectl-plugin-ssh-jump](#kubectl-plugin-ssh-jump)\n\t- [Pre-requistes](#pre-requistes)\n\t- [Installation](#installation)\n\t\t- [Install through krew](#install-through-krew)\n\t\t- [Manual Installation](#manual-installation)\n\t- [How to use](#how-to-use)\n\t\t- [Usage](#usage)\n\t\t\t- [Option parameters Cache](#option-parameters-cache)\n\t\t\t- [SSH Agent ssh-agent](#ssh-agent-ssh-agent)\n\t\t- [Customize SSH jump pod](#customize-ssh-jump-pod)\n\t\t- [Examples](#examples)\n\t\t\t- [CASE 1: SSH into Kubernetes nodes via SSH jump Pod](#case-1-ssh-into-kubernetes-nodes-via-ssh-jump-pod)\n\t\t\t\t- [-1 - You have private \u0026 public SSH key on your side](#-1---you-have-private--public-ssh-key-on-your-side)\n\t\t\t\t- [-2 - You have .pem file but you don't have public key on your side](#-2---you-have-pem-file-but-you-dont-have-public-key-on-your-side)\n\t\t\t- [CASE 2: Access remote serivces via SSH local port forwarding](#case-2-access-remote-serivces-via-ssh-local-port-forwarding)\n\t\t\t\t- [-1 - Configuring SSH local port forwarding with --args or -a option](#-1---configuring-ssh-local-port-forwarding-with---args-or--a-option)\n\t- [Useful Links](#useful-links)\n\t- [Contributing](#contributing)\n\n\u003c!-- /TOC --\u003e\n\n\n## Pre-requistes\nThis plugin needs the following programs:\n* ssh(1)\t\n* ssh-agent(1)\n* ssh-keygen(1)\n\n## Installation\n\n### Install through krew\nThis is a way to install kubectl-ssh-jump through [krew](https://krew.sigs.k8s.io/). After installing krew by following [this](https://krew.sigs.k8s.io/docs/user-guide/setup/install/), you can install kubectl-ssh-jump like this:\n\n```sh\n$ kubectl krew install ssh-jump\n```\n\nExpected output would be like this:\n```\nUpdated the local copy of plugin index.\nInstalling plugin: ssh-jump\nCAVEATS:\n\\\n |  This plugin needs the following programs:\n |  * ssh(1)\n |  * ssh-agent(1)\n |\n |  Please follow the documentation: https://github.com/yokawasa/kubectl-plugin-ssh-jump\n/\nInstalled plugin: ssh-jump\n```\n\nOnce it's installed, run:\n```sh\n$ kubectl plugin list\n\nThe following kubectl-compatible plugins are available:\n\n/Users/yoichi.kawasaki/.krew/bin/kubectl-krew\n/Users/yoichi.kawasaki/.krew/bin/kubectl-ssh_jump\n\n$ kubectl ssh-jump\n```\n\n### Manual Installation\n\nInstall the plugin by copying the script in the $PATH of your shell.\n\n```sh\n# Get source\n$ git clone https://github.com/yokawasa/kubectl-plugin-ssh-jump.git\n$ cd kubectl-plugin-ssh-jump\n$ chmod +x kubectl-ssh-jump\n# Add kubeclt-ssh-jump to the install path.\n$ sudo cp -p kubectl-ssh-jump /usr/local/bin\n```\n\nOnce in the $PATH, run:\n```sh\n$ kubectl plugin list\n\nThe following kubectl-compatible plugins are available:\n/usr/local/bin/kubectl-ssh-jump\n\n$ kubectl ssh-jump\n```\n\n## How to use\n\n### Usage\n\n```TXT\nUsage: \n  kubectl ssh-jump \u003cdest_node\u003e [options]\n\nOptions:\n  \u003cdest_node\u003e                     Destination node name or IP address\n                                  dest_node must start from the following letters:\n                                  ASCII letters 'a' through 'z' or 'A' through 'Z',\n                                  the digits '0' through '9', or hyphen ('-').\n                                  NOTE: Setting dest_node as 'jumphost' allows to\n                                  ssh into SSH jump Pod as 'root' user\n  -u, --user \u003csshuser\u003e            SSH User name\n  -i, --identity \u003cidentity_file\u003e  Identity key file, or PEM(Privacy Enhanced Mail)\n  -p, --pubkey \u003cpub_key_file\u003e     Public key file\n  -P, --port \u003cport\u003e               SSH port for target node SSH server\n                                  Defaults to 22\n  -a, --args \u003cargs\u003e               Args to exec in ssh session\n  -n, --namespace \u003cns\u003e            Namespace for jump pod\n  --context \u003ccontext\u003e             Kubernetes context\n  --pod-template \u003cfile\u003e           Path to custom sshjump pod definition\n  -l, --labels \u003ckey\u003e=\u003cval\u003e[,...]  Find a pre-existing sshjump pod using labels\n  --skip-agent                    Skip automatically starting SSH agent and adding\n                                  SSH Identity key into the agent before SSH login\n                                  (=\u003e You need to manage SSH agent by yourself)\n  --cleanup-agent                 Clearning up SSH agent at the end\n                                  The agent is NOT cleaned up in case that\n                                  --skip-agent option is given\n  --cleanup-jump                  Clearning up sshjump pod at the end\n                                  Defaults to skip cleaning up sshjump pod\n  -v, --verbose                   Run ssh in verbose mode (=ssh -vvv)\n  -h, --help                      Show this message\n\nExample:\n  Scenario1 - You have private \u0026 public SSH key on your side\n  $ kubectl ssh-jump -u myuser -i ~/.ssh/id_rsa -p ~/.ssh/id_rsa.pub hostname\n\n  Scenario2 - You have .pem file but you don't have public key on your side\n  $ kubectl ssh-jump -u ec2-user -i ~/.ssh/mykey.pem hostname\n```\n\n#### Option parameters Cache\n\n`username`, `identity`, `pubkey`, `port` options are cached, therefore you can omit these options afterward. The options are stored in a file named `$HOME/.kube/kubectlssh/options`\n\n```sh\n$ cat $HOME/.kube/kubectlssh/options\nsshuser=myuser\nidentity=/Users/yoichi.kawasaki/.ssh/id_rsa_k8s\npubkey=/Users/yoichi.kawasaki/.ssh/id_rsa_k8s.pub\nport=22\n```\n\n#### SSH Agent (ssh-agent)\n\nThe plugin automatically check if there are any `ssh-agents` started running by the plugin, and starts `ssh-agent`if it doesn't find any `ssh-agent` running and adds SSH Identity key into the agent before SSH login. If the command find that ssh-agent is already running, it doesn't start a new agent, and re-use the agent.\nAdd `--cleanup-agent` option if you want to kill the created agent at the end of command.\n\nIn addtion, add `--skip-agent` option if you want to skip automatic starting `ssh-agent`. This is actually a case where you already have ssh-agent managed or you want to manually start the agent.\n\n### Customize SSH jump pod\n\nYou can customize the sshjump pod created by `kubectl ssh-jump` by setting the `--pod-template` flag to the path to a pod template on disk.\nHowever, customized sshjump pods must be named `sshjump` and run in the current namespace or `kubectl ssh-jump` won't be able to find them without the required flags.\nIf you change the pod name, you must give the pod a unique set of labels and provide them on the command line by setting the `--labels` flag.\n\nYou can also specify the namespace and context used by `kubectl ssh-jump` by setting the `--namespace` and `--context` flags respectively.\n\n### Examples\n\nShow all node list. Simply executing `kubectl ssh-jump` gives you the list of destination nodes as well as command usage\n\n```sh\n$ kubectl ssh-jump\n\nUsage: \n  kubectl ssh-jump \u003cdest_node\u003e [options]\n\n...snip...\n\nList of destination node...\nHostname                    Internal-IP\naks-nodepool1-18558189-0    10.240.0.4\n...snip...\n```\n\n\n#### CASE 1: SSH into Kubernetes nodes via SSH jump Pod\n\n##### 1-1 - You have private \u0026 public SSH key on your side\n\nSuppose you have private \u0026 public SSH key on your side and you want to SSH to a node named `aks-nodepool1-18558189-0`, execute the plugin with options like this:\n\n- usernaem: `azureuser`\n- identity:`~/.ssh/id_rsa_k8s`\n- pubkey:`~/.ssh/id_rsa_k8s.pub`)\n\n```sh\n$ kubectl ssh-jump aks-nodepool1-18558189-0 \\\n  -u azureuser -i ~/.ssh/id_rsa_k8s -p ~/.ssh/id_rsa_k8s.pub\n```\n\n\u003e [NOTE] you can try SSH into a node using node IP address (`Internal-IP`) instead of `Hostname`\n\nAs explained in usage secion, `username`, `identity`, `pubkey` options will be cached, therefore you can omit these options afterward.\n\n```sh\n$ kubectl ssh-jump aks-nodepool1-18558189-0\n```\n\nYou can pass the commands to run in the destination node like this (Suppose that `username`, `identity`, `pubkey` options are cached):\n```sh\necho \"uname -a\" | kubectl ssh-jump aks-nodepool1-18558189-0\n\n(Output)\nLinux aks-nodepool1-18558189-0 4.15.0-1035-azure #36~16.04.1-Ubuntu SMP Fri Nov 30 15:25:49 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux\n```\n\nYou can pass commands with `--args` or `-a` option\n``` sh\nkubectl ssh-jump aks-nodepool1-18558189-0 --args \"uname -a\"\n\n(Output)\nLinux aks-nodepool1-18558189-0 4.15.0-1035-azure #36~16.04.1-Ubuntu SMP Fri Nov 30 15:25:49 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux\n```\n\nYou can clean up sshjump pod at the end of the command with `--cleanup-jump` option, otherwise, the sshjump pod stay running by default.\n\n```sh\n$ kubectl ssh-jump aks-nodepool1-18558189-0 \\\n  -u azureuser -i ~/.ssh/id_rsa_k8s -p ~/.ssh/id_rsa_k8s.pub \\\n  --cleanup-jump\n```\n\nYou can clean up ssh-agent at the end of the command with `--cleanup-agent` option, otherwise, the ssh-agent process stay running once it's started.\n\n```sh\n$ kubectl ssh-jump aks-nodepool1-18558189-0 \\\n  -u azureuser -i ~/.ssh/id_rsa_k8s -p ~/.ssh/id_rsa_k8s.pub \\\n  --cleanup-agent\n```\n\nYou can skip starting `ssh-agent` by giving `--skip-agent`. This is actually a case where you already have ssh-agent managed. Or you can start new ssh-agent and add an identity key to the ssh-agent like this:\n\n```sh\n# Start ssh-agent manually\n$ eval `ssh-agent`\n# Add an arbitrary private key, give the path of the key file as an argument to ssh-add\n$ ssh-add ~/.ssh/id_rsa_k8s\n# Then, run the plugin with --skip-agent\n$ kubectl ssh-jump aks-nodepool1-18558189-0 \\\n  -u azureuser -i ~/.ssh/id_rsa_k8s -p ~/.ssh/id_rsa_k8s.pub \\\n  --skip-agent\n\n# At the end, run this if you want to kill the current agent\n$ ssh-agent -k\n```\n\n##### 1-2 - You have .pem file but you don't have public key on your side\n\nFrom v0.4.0, the plugin supports PEM (Privacy Enhanced Mail) scenario where you create key-pair but you only have .pem / private key (downloaded from AWS, for example) and you don't have the public key on your side.\n\nSuppose you've already downloaded a pem file and you want to ssh to your EKS worker node (EC2) named `ip-10-173-62-96.ap-northeast-1.compute.internal` using the pem, execute the plugin with options like this:\n\n- usernaem: `ec2-user`\n- identity: `~/.ssh/mykey.pem`\n\n```sh\n$ kubectl ssh-jump -u ec2-user -i ~/.ssh/mykey.pem ip-10-173-62-96.ap-northeast-1.compute.internal\n```\n#### CASE 2: Access remote serivces via SSH local port forwarding\n\nSSH local port forwarding allows to forward the traffic form local machine to SSH jump then SSH jump will forward the traffic to remote services (host:port)s.\n##### 2-1 - Configuring SSH local port forwarding with --args or -a option\n\nSuppose you have private \u0026 public SSH key on your side and you want to access a remote server (IP: `10.100.10.8`) using `3389`/TCP port which is not accessible directly but accessible via SSH jump, execute the plugin with options like this, at first:\n\n- identity:`~/.ssh/id_rsa_k8s`\n- pubkey:`~/.ssh/id_rsa_k8s.pub`)\n\n The command below allows to forward the traffic form local machine (`localhost:13200`) to SSH jump then SSH jump will forward the traffic to the remote server (`10.100.10.8:3389`). \n```sh\n$ kubectl ssh-jump sshjump \\\n  -i ~/.ssh/id_rsa_k8s -p ~/.ssh/id_rsa_k8s.pub \\\n  -a \"-L 13200:10.100.10.8:3389\"\n```\n\u003e - `sshjump` is the hostname for SSH jump Pod\n\u003e -  The value for `--arg` or `-a` should be in this format: \"-L local_port:remote_address:remote_port\"\n\nNow, you're ready to access to the remote server at port 13200 at local machine.\n\n## Useful Links\n\n- [Extend kubectl with plugins](https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/)\n- [Write your own kubectl subcommands](https://ahmet.im/blog/kubectl-plugins/)\n- [SSH-AGENT - SINGLE SIGN-ON USING SSH](https://www.ssh.com/ssh/agent)\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/yokawasa/kubectl-plugin-ssh-jump\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyokawasa%2Fkubectl-plugin-ssh-jump","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyokawasa%2Fkubectl-plugin-ssh-jump","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyokawasa%2Fkubectl-plugin-ssh-jump/lists"}