Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当我试图通过sshpass运行kubectl命令时,它失败了,无法连接到服务器_Ssh_Kubernetes_Kubectl_Sshpass - Fatal编程技术网

当我试图通过sshpass运行kubectl命令时,它失败了,无法连接到服务器

当我试图通过sshpass运行kubectl命令时,它失败了,无法连接到服务器,ssh,kubernetes,kubectl,sshpass,Ssh,Kubernetes,Kubectl,Sshpass,我使用了这样的命令: sshpass -p password ssh root@x.x.x.x 'date;kubectl get pod;date' 我得到: Wed Sep 20 14:39:19 CST 2017 Unable to connect to the server: EOF Wed Sep 20 14:39:20 CST 2017 如何解决这个问题 所有kubectl命令在目标系统上运行良好。 命令: 也可以很好地工作: mynode /etc » sshpass -p

我使用了这样的命令:

sshpass -p password ssh root@x.x.x.x 'date;kubectl get pod;date' 
我得到:

Wed Sep 20 14:39:19 CST 2017
Unable to connect to the server: EOF
Wed Sep 20 14:39:20 CST 2017
如何解决这个问题

所有kubectl命令在目标系统上运行良好。 命令:

也可以很好地工作:

 mynode /etc » sshpass -p password ssh -o StrictHostKeyChecking=no root@x.x.x.x "kubectl"                                                        
kubectl controls the Kubernetes cluster manager. 

Find more information at https://github.com/kubernetes/kubernetes.

Basic Commands (Beginner):
  create         Create a resource by filename or stdin
  expose         Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service
  run            Run a particular image on the cluster
  set            Set specific features on objects

Basic Commands (Intermediate):
  get            Display one or many resources
  explain        Documentation of resources
  edit           Edit a resource on the server
  delete         Delete resources by filenames, stdin, resources and names, or by resources and label selector
...

你能试试这样跑吗

ssh master-01 -x 'kubectl --kubeconfig=/root/.kube/config get nodes'
在您这样的情况下:

 sshpass -p password  ssh master-01 -x 'kubectl --kubeconfig=/root/.kube/config get nodes'

请参阅,您可以通过k8s配置文件并对其进行测试
kubectl--kubeconfig=kube-config的路径
很抱歉,我不明白你的意思,我忘了提供一些重要信息。请看上面的问题。
 sshpass -p password  ssh master-01 -x 'kubectl --kubeconfig=/root/.kube/config get nodes'