🎈
Luftballon makes a sshtunnel for your Raspberry Pi via an AWS EC2 instance by one command.
- Have an AWS account
- Luftballon must be on Treehouses image
- Have a pair of ssh key (public key's name must be id_rsa.pub)
At first, you need to have AWS CLI on your Raspberry Pi. If you have the AWS CLI, and it is propely configured, you can skip it
If you do not have AWS CLI on your Raspberry Pi, execute the below script.
./installAwsCli.sh
Then, configure your AWS CLI with aws configure
.
Please consult this page for setting up your AWS CLI if you use the AWS CLI at the first time.
Also, this page
explains the configuration basics.
Note Please set up the output format as
json
The below is the example of the config.
AWS Access Key ID [***your access key***]
AWS Secret Access Key [***your access key***]
Default region name [your region]:
Default output format [json]:
If you have the properly configured AWS CLI, you can start Luftballon by a command.
Execute the below command
./up.sh
This command does several things
- Add ssh key on the AWS EC2 portal
- Make security group on the EC2 portal
- Configure security group (Open ports)
- Create EC2 instance
- Record EC2 instance ID and the ip address of the EC2 instance
- Open a sshtunnel
If the command succeeds, you will get the output on your command screen like below.
Below sshtunnels are configured
root@[ip address of EC2]:2200 2222:22
The ip address is assigned by AWS, so it is not fixed value.
Then, go to a different device such as your laptop, and execute the below command.
ssh -p 2222 root@[ip address]
You can login to your Raspberry Pi via the EC2 instance.
./up.sh -a [name]
This a flag changes three names
- key name
- Security group name
- EC2 Instance name
./stop.sh [name]
./start.sh [name]
The up.sh only makes the sshtunnel connecting the port 2222 of EC2 instance to the port 22 of the Raspberry Pi. You can make another sshtunnel by the below command.
./addPort.sh [EC2 port number] [Raspberry Pi port number]
For example, ./addPort.sh 8080 80
makes the sshtunnel between the port 8080 of the EC2 and the port 80 of the Raspberry Pi.
If you host a web application on your Raspberry Pi on the port 80, people can access to the application via [ip address of the EC2]:8080
You can down the sshtunnel by the below command
./deletePort.sh [EC2 port number] [Raspberry Pi port number]
It is nice to connect to your Raspberry Pi by sshtunnel, but you have to pay money to Amazon to have the sshtunnels. If you do not need to use the sshtunnel, you do not want to pay money for nothing.
The below comand down the Luftballon.
./down.sh
This command basically does the opposite of the up.sh
- Close sshtunnels
- Delete EC2 instance
- Delete security group on the EC2 portal
- Delete ssh key on the AWS EC2 portal
The sshConfigManager
interface is designed to facilitate the management of SSH configurations, providing methods to create, update, and delete SSH configuration entries. This interface streamlines the process of maintaining complex SSH config files, making it easier to manage access to multiple remote servers.
What it does:
The create
command generates a new entry in the SSH configuration file with detailed settings for host alias, hostname, user, port, identity file, and port forwarding options.
How to execute:
To add a new SSH configuration entry:
create "myserver" "example.com" "user" "22" "~/.ssh/id_rsa" "8888:80,9999:443"
This command sets up a host with alias myserver
, connecting to example.com
on port 22 with the specified identity file and port forwarding settings.
What it does:
The update
command modifies an existing SSH configuration entry for a specified host. It can change settings for any key such as User
, Port
, or complex keys like RemoteForward
, where both old and new port forwarding settings need to be specified.
How to execute:
To change the User
for host myserver
:
update myserver User newuser
To update a RemoteForward
setting:
update myserver RemoteForward 8888:80 8899:80
These commands adjust the specified configurations, replacing old values with new ones.
What it does:
The down
command removes an entire SSH configuration block for a specified host from the SSH config file, effectively discontinuing the SSH management for that host through the configuration file.
How to execute:
To remove the configuration for a host:
down myserver
This command deletes all settings associated with the host myserver
, cleaning up the SSH config file by removing unused or outdated entries.