|
| 1 | +# Bastion Session Script |
| 2 | + |
| 3 | +This shell script can be used to easily connect to the OCI Bastion service based on temporary SSH keys. Authorization is granted based on OCI CLI authentication and OCI Permissions. For OCI CLI authentication both the use of exchanged API keys and session security tokens is supported. This script works also directly on OCI Cloud Shell, however only for Managed SSH Sessions since port forwarding is not supported on OCI Cloud Shell. |
| 4 | + |
| 5 | +## When to use this asset? |
| 6 | + |
| 7 | +Use this shell script if you want to make use of OCI Bastions in a simple and secure way. |
| 8 | + |
| 9 | +## How to use this asset? |
| 10 | + |
| 11 | +**Usage: ./bastion-session.sh COMMAND [ARGS]...** |
| 12 | + |
| 13 | +Example: |
| 14 | + |
| 15 | +```text |
| 16 | +./bastion-session.sh ssh -b bst001 -i instance-001 -u opc [-p <oci profile>] |
| 17 | +./bastion-session.sh pf -b bst001 -d 10.0.0.1 -e 3389 [-p <oci profile>] [-l <local port>] |
| 18 | +``` |
| 19 | + |
| 20 | +**Commands:** |
| 21 | + |
| 22 | + ssh : The session type "ssh" for Managed SSH session. |
| 23 | + |
| 24 | + pf : The session type "pf" for Port Forwarding session. |
| 25 | + |
| 26 | +**Arguments:** |
| 27 | + |
| 28 | +| short | long | description | |
| 29 | +|----|-----------------------------|---| |
| 30 | +| -b | --bastion TEXT | The Name of the Bastion to be used. [-b or -c is required]| |
| 31 | +| -c | --bastion-ocid TEXT | The OCID of the Bastion to be used. [-b or -c is required]| |
| 32 | +| -i | --instance TEXT | The name of the target instance to be used.| |
| 33 | +| -j | --instance-ocid TEXT | The OCID of the target instance to be used.| |
| 34 | +| -u | --username TEXT | The target resource username to be used. [default: opc]| |
| 35 | +| -p | --profile TEXT | The oci profile in the config file to load. [default: DEFAULT]| |
| 36 | +| -s | --session TEXT | The Bastion session name. [default: Bastion-Session]| |
| 37 | +| -t | --ttl INTEGER | The Bastion session time-to-live in seconds, minimum 1800, maximum 10800. [default: 10800]| |
| 38 | +| -d | --destination-ip IP | The destination IP Address to be used for Bastion session. [default: the first private ip address of instance]| |
| 39 | +| -e | --destination-port INTEGER | The destination port to be used for Port Forwarding session. [default: 22]| |
| 40 | +| -l | --local-port INTEGER | The local port to be used for Port Forwarding session. [defaults to same value as destination port]| |
| 41 | +| -a | --key-alg TEXT | The algorithm for the SSH key (ssh-keygen) to be used. [default: rsa]| |
| 42 | +| -k | --key-size INTEGER | The key size for the SSH key (ssh-keygen) to be used. [default: 4096]| |
| 43 | +| -pr| --private-key TEXT | The private key file to be used when not generating a temporary key pair. [by default not used]| |
| 44 | +| -pu| --public-key TEXT | The public key file to be used when not generating a temporary key pair. [by default not used]| |
| 45 | +| -v | --verbose | Show verbose output for troubleshooting.| |
| 46 | + |
| 47 | +Prerequisites: |
| 48 | + |
| 49 | +- The OCI Command Line Interface (CLI) must be installed and configured. |
| 50 | + (See also [https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/cliinstall.htm]) |
| 51 | +- The jq commandline JSON processer must be installed. |
| 52 | + (See also [https://stedolan.github.io/jq]) |
| 53 | + |
| 54 | +# License |
| 55 | + |
| 56 | +Copyright (c) 2023 Oracle and/or its affiliates. |
| 57 | + |
| 58 | +Licensed under the Universal Permissive License (UPL), Version 1.0. |
| 59 | + |
| 60 | +See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE) for more details. |
0 commit comments