Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 1.32 KB

README.md

File metadata and controls

45 lines (34 loc) · 1.32 KB

996.icu LICENSE

k8s-ssh-pod

example for ssh to kubernetes containers. support audit log for input command

run server

% go run ./bin/main.go --help
Usage of /var/folders/j4/lf3vdk9n1fz_cf5ymm0pw4sh0000gn/T/go-build1832716769/b001/exe/main:
  -address string
        Address to start SSH Server (default ":2222")
  -audit
        audit log for input command
  -hostkey string
        Path to the Host Key (default "$HOME/.ssh/id_rsa")
  -in-k8s-cluster
        Is running in Kubernetes cluster? load k8s configuration from --kubeconfig if not
  -kubeconfig string
        Path to the kubernetes configuration (default "$HOME/.kube/config")
        
% go run ./bin/main.go 
2023/08/19 18:54:40 Use Host Key /Users/sope/.ssh/id_rsa
2023/08/19 18:54:40 Initialize k8s client with config file: /Users/sope/.kube/config
2023/08/19 18:54:40 Start SSH Server at :2222

ssh client

open new terimal

ssh -p 2222 localhost

select namespace

select pod (default select the first container in pod to exec in)

shell in container