Need to do ssh to Kubernetes pod

8/16/2017

Is it possible to take ssh to pod. eg: ssh pod_ip

I know we can do this with kubectl command. But I need to do ssh from my local linux machine where I doesn't have kubectl

Thanks

-- Eswari
kubernetes

2 Answers

8/16/2017

Firstly, you have to ensure that the openssh-server has been installed and running in the pod. If not, you can use kubectl exec -it <pod-name> -n <namespace> -- bash to access the pod. If your pod are running Ubuntu, do apt-get install -y openssh-server.

Secondly, pods are running in a virtual IP subnet assigned by network service. They are accessible to any Master nodes and Worker nodes in the cluster. You can do ssh from any of the Host OS.

-- ichbinblau
Source: StackOverflow

4/29/2019

If you would like to login inside a particular container in the POD

kubectl exec -it <Pod_Name> -c <Container_Name> -- /bin/bash

If you would like to login to default container (or if there is only one container in POD) then just use

kubectl exec -it <Pod_Name> -- /bin/bash

PS:- If /bin/bash is not working try /bin/sh

-- nagendra547
Source: StackOverflow