<p>I couldn't find an equivalent k8s cli command to do something like this, nor any ssh keys stored as k8s secrets. It also appears to do this in a cloud-agnostic fashion.</p>
<p>Is it just using a k8s pod with special privileges or something?</p>
<p>Edit: oops, it's open-source. I'll investigate and update this question accordingly</p>

Avi Mosseri
<p>Posting this community wiki answer to give more visibility on the comment that was made at a github issue that addressed this question:</p>
<blockquote>
<p>Lens will create <code>nsenter</code> pod to the selected node</p>
<blockquote>
<pre><code>protected async createNodeShellPod(podId: string, nodeName: string) { 
  const kc = this.getKubeConfig(); 
  const k8sApi = kc.makeApiClient(k8s.CoreV1Api); 
  const pod = { 
    metadata: { 
      name: podId, 
      namespace: &quot;kube-system&quot; 
    }, 
    spec: { 
      restartPolicy: &quot;Never&quot;, 
      terminationGracePeriodSeconds: 0, 
      hostPID: true, 
      hostIPC: true, 
      hostNetwork: true, 
      tolerations: [{ 
        operator: &quot;Exists&quot; 
      }], 
      containers: [{ 
        name: &quot;shell&quot;, 
        image: &quot;docker.io/alpine:3.9&quot;, 
        securityContext: { 
          privileged: true, 
        }, 
        command: [&quot;nsenter&quot;], 
        args: [&quot;-t&quot;, &quot;1&quot;, &quot;-m&quot;, &quot;-u&quot;, &quot;-i&quot;, &quot;-n&quot;, &quot;sleep&quot;, &quot;14000&quot;] 
      }], 
      nodeSelector: { 
        &quot;kubernetes.io/hostname&quot;: nodeName 
      } 
    } 
  } as k8s.V1Pod; 
</code></pre>
</blockquote>
<p>and exec into that container in lens terminal.</p>
<p>-- <em><a href="https://github.com/lensapp/lens/issues/824#issuecomment-688826431" rel="noreferrer">Github.com: Lensapp: Issues: How Lens accessing nodes in AKS/EKS without user and SSH key under ROOT?</a></em></p>
</blockquote>
<hr />
<p>I've checked this and as it can be seen below the <code>Pod</code> with <code>nsenter</code> is created in the <code>kube-system</code> (checked on <code>GKE</code>):</p>
<ul>
<li><code>$ kubectl get pods -n kube-system</code> (output redacted)</li>
</ul>
<pre class="lang-sh prettyprint-override"><code>kube-system   node-shell-09f6baaf-dc4a-4faa-969e-8016490eb8e0             1/1     Running   0          10m
</code></pre>
<hr />
<p>Additional resources:</p>
<ul>
<li><em><a href="https://github.com/lensapp/lens/issues/295" rel="noreferrer">Github.com: Lensapp: Lens: Issues: How does lens use terminal/ssh for worker nodes?</a></em></li>
<li><em><a href="https://man7.org/linux/man-pages/man1/nsenter.1.html" rel="noreferrer">Man7.org: Linux: Man pages: Nsenter</a></em></li>
</ul>
