kops ssh public key permission denied

3/29/2019

I am trying to create a cluster via kops, following these instructions https://github.com/kubernetes/kops/blob/master/docs/cli/kops_create_cluster.md

This is what i tried

export AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id)
export AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key)
export KOPS_CLUSTER_NAME=staging.fayzlab.com
export KOPS_STATE_STORE=s3://fayzlab-kops-stat-store

aws s3api create-bucket \
--bucket fayzlab-kops-stat-store \
--region us-east-1

aws s3api put-bucket-versioning --bucket fayzlab-kops-stat-store --versioning-configuration Status=Enabled

kops create cluster \
    --zones us-east-1b \
    --topology private \
    --networking calico \
    --api-ssl-certificate arn:aws:acm:us-east-1:679995182974:certificate/b1753864-f1b7-4a51-a008-cb14f07544ab \
    --master-size t2.micro\
    --master-count 1 \
    --node-size t2.micro \
    --node-count 1 \
    --name ${KOPS_CLUSTER_NAME}

I got the following output

{
    "Location": "/fayzlab-kops-stat-store"
}
I0329 17:58:56.299037   32539 create_cluster.go:496] Inferred --cloud=aws from zone "us-east-1b"
I0329 17:58:57.216939   32539 subnets.go:184] Assigned CIDR 172.20.32.0/19 to subnet us-east-1b
I0329 17:58:57.217040   32539 subnets.go:198] Assigned CIDR 172.20.0.0/22 to subnet utility-us-east-1b
Previewing changes that will be made:


SSH public key must be specified when running with AWS (create with `kops create secret --name staging.fayzlab.com sshpublickey admin -i ~/.ssh/id_rsa.pub`)

I created a key ssh-keygen -t rsa -f ./cluster.fayzlab.com

and tried

kops create secret sshpublickey admin -i ~/.ssh/cluster.fayzlab.com.pub \
  --name staging.fayzlab.com --state s3://fayzlab-kops-stat-store

but i am getting this error

error reading SSH public key /home/faiz/.ssh/cluster.fayzlab.com.pub: open /home/faiz/.ssh/cluster.fayzlab.com.pub: permission denied

I have exhausted all my options and resources online. Please advise.

Permissions on file

-rw------- 1 faiz faiz 1766 Mar 29 17:51 cluster.fayzlab.com
-rw-r--r-- 1 faiz faiz  391 Mar 29 17:51 cluster.fayzlab.com.pub
-- f_i
amazon-web-services
kops
kubernetes

1 Answer

4/9/2019

Option I

1) Change working dir to

cd ~/.ssh/

2) And run a command again as follows

kops create secret sshpublickey admin -i cluster.fayzlab.com.pub --name staging.fayzlab.com --state s3://fayzlab-kops-stat-store

Option II

Provide full path to your public key, i.e.

kops create secret sshpublickey admin -i /home/faiz/.ssh/cluster.fayzlab.com.pub --name staging.fayzlab.com --state s3://fayzlab-kops-stat-store
-- A_Suh
Source: StackOverflow