Why I can not install plugins Compute engine instance? HTTP ERROR 401 Unauthorized

Viewed 23

I created GCP VM instance and I can SSH.

miki@devsecops-cloud:~/kubernetes-devops-security/setup/jenkins-plugins$ ls -la
total 16
drwxrwxr-x 2 miki miki 4096 Sep 20 10:36 .
drwxrwxr-x 6 miki miki 4096 Sep 20 10:36 ..
-rw-rw-r-- 1 miki miki 1100 Sep 20 10:36 plugin-installer.sh
-rw-rw-r-- 1 miki miki  171 Sep 20 10:36 plugins.txt

Now the next step is to install Jenkins plugins from bash script. Well it does not work at all. I go this error

sudo bash plugin-installer.sh 
parse error: Invalid numeric literal at line 2, column 0
parse error: Invalid numeric literal at line 2, column 0
http://localhost:8080


........Installing performance@3.18 ..
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 401 Unauthorized</title>
</head>
<body><h2>HTTP ERROR 401 Unauthorized</h2>
<table>
<tr><th>URI:</th><td>/pluginManager/installNecessaryPlugins</td></tr>
<tr><th>STATUS:</th><td>401</td></tr>
<tr><th>MESSAGE:</th><td>Unauthorized</td></tr>
<tr><th>SERVLET:</th><td>Stapler</td></tr>
</table>
<hr/><a href="https://eclipse.org/jetty">Powered by Jetty:// 10.0.11</a><hr/>

may be problem is that I pointed to credentials at host machine

export GOOGLE_APPLICATION_CREDENTIALS=/home/miki/.config/gcloud/application_default_credentials.json

On the host,account list

gcloud auth list
       Credentialed Accounts
ACTIVE  ACCOUNT
*       johnholmes@gmail.com

To set the active account, run:
    $ gcloud config set account `ACCOUNT

On the VM

gcloud auth list
                  Credentialed Accounts
ACTIVE  ACCOUNT
*       931909916149-compute@developer.gserviceaccount.com

To set the active account, run:
    $ gcloud config set account `ACCOUNT`

On VM I tried to login

gcloud auth login
Your credentials may be visible to others with access to this
virtual machine. Are you sure you want to authenticate with
your personal account?

Do you want to continue (Y/n)?  y

Go to the following link in your browser:

    https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32312940559.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fsdk.cloud.google.com%2Fauthcode.html&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice.login+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=emNPFQkW7AHLJG97s6QGUqRSvvpCVV&prompt=consent&access_type=offline&code_challenge=LtH3n7LWTG8SZfOBT8jKZTrkb-fWECYekLVKNn2REBo&code_challenge_method=S256

Enter authorization code: 4/0ARtbsJrLZR41bqLkT2--0J9vOllonBoA2NU2l7NcI7nMGD0nbjFiRFSRkj2Cr7mjlADhHw

You are now logged in as [johnholmes@gmail.com].

But same problems are still here,401 error.

How to setup a proper credentials on VM machine?

0 Answers
Related