Connect to the database using an SSH tunnel and switch users
Answered
I want to connect to db2 using DataGrip.
To access the server where db2 is running, I need to use an SSH tunnel.
The user for SSH and the user who can access db2 are different.
When accessing db2 from the terminal, the following steps are required.
Is there a way to perform the sudo su - user2
part in DataGrip's DB connection settings?
ssh {user1}@{server IP}
sudo su - user2
db2 connect to {DB Name} user {user2} using {password}
Please sign in to leave a comment.
Unfortunately no, DataGrip does not natively support a way to run this command after using the SSH Tunnel;
As a workaround, you can install the Terminal plugin on Datagrip at Settings | Plugins | Marketplace. Then, try manually setting up the SSH tunnel on the terminal and configure to use the user2 directly
Thank you for your reply.
I have confirmed that communication via Terminal is possible.
What I wanted to ask this time is whether it is possible to connect with SSH tunnel using user1 and then change to user2 for DB connection execution.
In cases where the SSH user and DB connection user are different, does this mean that it is not possible to connect with DataGrip?