Add the debug to your agent to your java program or server
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar your-app.jar
Use the below command to port forward using your bastion host
ssh -i ~/.ssh/remote.pem -o "ProxyCommand ssh -i jumpboxkey.pem -W %h:%p ec2-user@<bastion-public-ip>" ec2-user@<private-ec2-ip> -L 5005:localhost:5005
Connect Intellij
Also there is a more secured approach to do the same using SSM port forwarding check the below article