| name | ssh |
| description | Manage SSH access to the OCI instance — open, connect, or close |
| disable-model-invocation | true |
| allowed-tools | Bash, Read |
| argument-hint | [allow|revoke|connect] |
SSH Access Management
Manage SSH access to the OCI compute instance. SSH is blocked by default and must be opened from a specific IP.
Arguments:
allow (default): Open SSH from the user's current public IP and apply the security list change
revoke: Close SSH access (remove the IP from the security list) and apply
connect: SSH into the instance
tunnel: Open MySQL SSH tunnel (localhost:3306)
Steps
allow (default)
- Get the user's public IPv4:
curl -4 -s --max-time 5 https://ifconfig.me
- Show the IP and confirm with the user
- Run:
terraform -chdir=terraform/environments/oci-prod apply -var="ssh_source_cidr=<IP>/32" -target=module.network.oci_core_security_list.main
revoke
- Run:
terraform -chdir=terraform/environments/oci-prod apply -var="ssh_source_cidr=" -target=module.network.oci_core_security_list.main
- Confirm SSH is now closed
connect
- Get instance IP:
terraform -chdir=terraform/environments/oci-prod output -raw instance_ip
- Run:
ssh ubuntu@<IP>
tunnel
- Get instance IP and MySQL IP from terraform outputs
- Run:
ssh -N -L 3306:<mysql_ip>:3306 ubuntu@<instance_ip>
- Tell the user to connect with:
mysql -h 127.0.0.1 -P 3306 -u admin -p