<p>Various Kubernetes security recommendations tell you to avoid SSH into containers and ask to use kubectl instead. The prime reason quoted is the possibility of escaping to the underlying host resources via SSH into containers. So, I have following specific queries:</p>

<ol>
<li><p>Which features of kubectl prevent you to access host resources and why ssh has more risk of accessing host resources as compared to kubectl? How kubectl is more secure?</p></li>
<li><p>Can SSH skip the Pod Security policies and access/mount paths on the underlying host which are restricted in pod security policy?</p></li>
<li><p>If SSH into containers is unavoidable, how to secure it in the best possible way?</p></li>
</ol>

Anuj
<p>Only because you have to run an <code>ssh</code> server in your container; thus an extra process running in your container, and have to manage the keys, is enough reason to not want to SSH into a container.</p>

<p>So, that's one drawback. Another one will go with the use case, and it's a risk. Why would you want to SSH into a container? One reason I see is because you want to do it from an external host (without <code>kubectl</code> installed and authenticated against <code>api-server</code>). So you have to expose an endpoint to outside world, or at least to your network.</p>
