Skip to content

Commit e1b0c03

Browse files
Merge pull request #8 from oracle-devrel/lvbirgelen-initial-bastion-session-script
Lvbirgelen initial bastion session script
2 parents 7334fc7 + 894a07a commit e1b0c03

File tree

4 files changed

+619
-0
lines changed

4 files changed

+619
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2023 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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

Comments
 (0)