Why am I getting a message that it can't log in when trying to use kubectl

I have a running k3s server that has worked great so I haven’t had to access it. Now I would like to change something but when I ssh into the server and run KUBECONFIG=/etc/rancher/k3s/k3s.yaml kubectl get pods -A I get error: You must be logged in to the server (Unauthorized). What am I missing?

I got the same issue here. Did you find the root cause?

Also when I try to access the k3s-cluster from the Rancher UI, everything seems to be okay, but it’s not possible to get logs or open a terminal on the containers. Rancher UI indicate that it is “Disconnected”.

When using the kubeconfig from Rancher, I get the following error with kubectl logs: “error: You must be logged in to the server (the server has asked for the client to provide credentials…”. Other commands like kubectl get ns work without problem.

@J_Gleason I found the issue. The certificates in my k3s were expired. A simple restart of the k3s service fixed the issue. See also Rancher Docs: Advanced Options and Configuration