# 登入Openshift出現,error: x509: certificate signed by unknown authority ###### tags: `openshift` 發生問題: 原本裝機的時候用root帳號裝的,在root帳號登入時,可以用oc login -u root 登入,但是在bastion上面由另一個使用者登入,卻無法使用oc login 登入,會遇到 error: x509: certificate signed by unkonwn authority的問題 參考網路上的文章: https://blog.pichuang.com.tw/20200427-openshift-with-coreos-part-5.html 是說這個問題是因為我用的bastion那一台沒有安裝openshift 自簽的憑證(CA),所以要從Openshift裡面拉出來安裝在bastion上面,或其他操作的機器上。 ```bash [root@bastion ~] oc login -u root [root@bastion ~] oc project openshift-authentication Now using project "openshift-authentication" on server "https://api.ocp.syc.com:6443". [root@bastion ~]# oc get po NAME READY STATUS RESTARTS AGE oauth-openshift-6895688bb8-g5nv8 1/1 Running 0 3d oauth-openshift-6895688bb8-vp8ww 1/1 Running 0 6d23h #將憑證copy到外面來 ```bash [root@bastion ~]# oc rsh oauth-openshift-6895688bb8-g5nv8 cat /run/secrets/kubernetes.io/serviceaccount/ca.crt > /home/${USER}/ocp4-ingress-ca.crt #以下的路徑是REHEL 7.x or CentOS 7.x適用 [root@bastion ~]# cp /home/${USER}/ocp4-ingress-ca.crt /etc/pki/ca-trust/source/anchors/ [root@bastion ~]# update-ca-trust extract ``` # 檢查憑證 [root@bastion ~]# openssl verify /etc/pki/ca-trust/source/anchors/ocp4-ingress-ca.crt /etc/pki/ca-trust/source/anchors/ocp4-ingress-ca.crt: OK # 測試一下是否可以用另一個使用者登入 [root@bastion ~]# exit logout [johnny@bastion ~]$ oc login Authentication required for https://api.ocp.syc.com:6443 (openshift) Username: johnny Password: Login successful. ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up