-
Notifications
You must be signed in to change notification settings - Fork 353
Authentication Issue When Connecting Through Bastion Host and IAP #2405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@hessjcg |
Hi @apolienko, When you enable IAM Auth, the proxy will use the IAM token from the machine where it is running. When you run the proxy locally, it will use your We recommend running the Auth Proxy locally, however, mainly for security reasons. -Jonathan |
@hessjcg |
@apolienko, unfortunately no. Private IP instances may only be accessed from VMs that are attached to the private network. Since you are already using a bastion host, you may need to log in to that host using SSH, authenticate the gcloud CLI, and then run the proxy and database client on the bastion host. https://cloud.google.com/sql/docs/mysql/connect-to-instance-from-outside-vpc has more details on how to connect to a Private IP instance from outside it's VPC. |
Basically bumping to the same limitation, I was even thinking of have some wrapper script and somehow pass the auth tho a docker container in the VM... alternatively we can use normal SQL users instead of IAM auth I suppose.... But considering google has IAP for other things I wonder if there are any plans for cloud-sql-proxy to one day support some from of IAP tunnel? Similar to how for SSH we can do tunnel-trought-IAP, though this might be more like a dream feature than something actually doable :D |
@mike-pt, we are considering ways to make this easier and an IAP tunnel directly to the DB is one of them. Until then, you can use IAP to connect to VM and then port forward to the db as described in Connect to an instance from outside vpc I hope that helps. |
Question
Environment
Problem
I'm trying to connect to a PostgreSQL instance in Google Cloud SQL from my local machine. The database has only a private IP address, so I'm using a bastion host to access it.
Bastion has a systemd service that is using
I've set up IAP TCP forwarding to the bastion host with this command:
When I try to connect through DBeaver using:
I receive the following error:
This setup previously worked when I was using cloud-sql-proxy locally. However, now that cloud-sql-proxy is running on the bastion host, the authentication fails.
What I've tried
I've confirmed that my user account has the necessary IAM permissions and has been added to Cloud SQL. The direct connection using cloud-sql-proxy from my local machine worked before, but I need to route through the bastion host now.
What might be causing this authentication failure, and how can I properly configure the connection to maintain IAM authentication while going through the bastion host?
Code
Additional Details
No response
The text was updated successfully, but these errors were encountered: