Codinn Store or Setapp version of Core Shell / Tunnel is required for setting environment variables
Use Advanced preferences to manage general environment variables for SSH and local terminal to use.
To add an environment variable, click the Add button (+) at the bottom of the Environment Variables table and enter the variable name and value.
Examples
Here we make examples of real-world usage scenarios to describe how environment variables can solve problems and simply your workflow.
Local Terminal
Environment variables are also handy for local terminals, for example, I set those variables to make my workflow simpler:
I can change current working directory to CoreShell
or CoreTunnel
by typing cd $CS
or cd $CT
, no lengthy full paths required.
SSH Port Forwarding to AWS EC2
Amazon EC2 users can tunnel SSH and SCP (Secure Copy) connections directly with the help of AWS Systems Manager Session Manager (SSM).
The general idea is it works through SSH’s ProxyCommand
. The ProxyCommand
option is used to invoke aws ssm start-session
to establish a connection between Core Shell/ Tunnel and sshd
on the target EC2, rather than connecting directly over port 22.
Most of the instructions work by setting up .ssh/config
to recognize any hostname of the form i-*
(EC2 instance ID) to be proxied through SSM.
# SSH over Session Manager
host i-* mi-*
ProxyCommand sh -c "aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
If you manually created a symlink file in folder /usr/local/bin/
that points to the aws
and aws_completer
programs (as recommend in Install the Session Manager plugin for the AWS CLI), you may be lucky enough to find that tunnel or terminal session are created as expected.
But if you install aws-cli
command via homebrew, then you may get this error message in Core Shell/ Tunnel:
sh: aws: command not found
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
Core Shell/ Tunnel could not find the aws
command installed by homebrew in default search paths. To solve this problem, you simply follow these steps:
-
First get the path of your
aws-cli
from command:which aws
-
Then print value of
PATH
environment in local terminal:echo $PATH
In my case, the value of
PATH
is:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin
Output may be different on your Mac. Make sure
aws
command in one of above folders. -
Go to Core Tunnel/ Shell Preferences… > Advanced > Environment Variables, add a new item, set Name to
PATH
, and Value to what printed previously.
-
Close the Preferences and connect the tunnel or open shell session again.
See also
- Installing, updating, and uninstalling the AWS CLI version 2 on macOS
- Step 8: (Optional) Enabling and controlling permissions for SSH connections through Session Manager
- New: Using Amazon EC2 Instance Connect for SSH access to your EC2 Instances
- New – Port Forwarding Using AWS System Manager Session Manager