Ensures you can access your computer from anywhere in the world with a single command. See why you need this, and how it works here.
Since you SSH from one computer (Leader) into another (Follower):
Leader - The pc that you use to control the server. Follower - The pc that follows the orders you give from the Leader.
You can use this repository in 2 ways:
- Run it once on the
Leader
(requires (local) ssh access fromLeader
intoFollower
) Run it once on theFollower
and once on theLeader
(Requires(physically) copying the onion domain and private key from Leader into~~Leader
).~~ (Currently not supported.)
To get the local ip address of the Follower
device, type:
hostname -I
on it. Which outputs something like:15.14.3.42
.
Then type:
whoami
to get the Ubuntu username of the Follower
, which outputs something like: somename
.
git clone https://github.com/HiveMinds/bash-ssh-over-tor.git
cd bash-ssh-over-tor
chmod +x install-dependencies.sh
./install-dependencies.sh
chmod +x src/main.sh
src/main.sh --follower
Open the terminal on the Leader
machine and type:
chmod +x install-dependencies.sh
./install-dependencies.sh
chmod +x src/main.sh
src/main.sh \
--leader \
--follower-username somename \
--follower-local-ip 15.14.3.42 \
--follower-password the_ubuntu_password_of_the_ubuntu_username
- Change these values with the output that you got at On Follower.
- You can also omit the password with:
--follower-password ""
if you don't want to type it in plain text, then you will be prompted for the password. - If you have to access the device on a specific port, for example for a
virtualbox system (HostIP=127.0.0.1, Host Port=2222, GuestIP=10.0.x.y,
GuestPort=22), include
--port 2222
where you change2222
with the port number you need. If you don't include it, it defaults to 22. Note for ssh into virtualbox do:ssh -p 2222 <ubuntu username>@127.0.0.1
.
That:
- Generates a private and public key pair on the
Leader
machine (and adds it to the ssh-agent of theLeader
machine). - Gets ssh access into
Follower
over WIFI/LAN. - Copies the public key from
Leader
intoFollower
. - Adds the copied public key to the authorised keys in the
Follower
machine. The output is the onion domain over which you can SSH into theFollower
machine, like:
You can ssh into # oncethis server with command:
torsocks ssh follower_ubuntu_username@somelongoniondomainabcdefghikjlmnop.onion
You can now SSH from your Leader
into your Follower
machine and tell it
what to do.
Currently not supported, feel free to send a pull request.
Below is information for developers, e.g. how to use this as a dependency in other projects.
- In your other repo, include a file named:
.gitmodules
that includes:
[submodule "dependencies/bash-ssh-over-tor"]
path = dependencies/bash-ssh-over-tor
url = https://github.com/hiveminds/bash-ssh-over-tor
- Create a file named
install-dependencies.sh
with content:
# Remove the submodules if they were still in the repo.
git rm --cached dependencies/bash-ssh-over-tor
# Remove and re-create the submodule directory.
rm -r "$SCRIPT_PATH/dependencies"/bash-ssh-over-tor
mkdir -p "$SCRIPT_PATH/dependencies"/bash-ssh-over-tor
# (Re) add the BATS submodules to this repository.
git submodule add --force https://github.com/hiveminds/bash-ssh-over-tor dependencies/bash-ssh-over-tor
- Install the submodule with:
chmod +x install-dependencies.sh
./install-dependencies.sh
After including this dependency you can use the functions in this module like:
#!/bin/bash
# Source the file containing the functions
source "$(dirname "${BASH_SOURCE[0]}")/src/main.sh"
# Naming conventions:
# server - The pc that you access and control.
# client - The pc that you use to control the server.
# Configure tor and ssh such that allows ssh access over tor.
configure_ssh_over_tor_at_boot
The 0
and 1
after the package name indicate whether it will update the
package manager afterwards (0
= no update, 1
= package manager update after
installation/removal)
Put your unit test files (with extension .bats) in folder: /test/
(Re)-install the required submodules with:
chmod +x install-dependencies.sh
./install-dependencies.sh
Install:
sudo gem install bats
sudo apt install bats -y
sudo gem install bashcov
sudo apt install shfmt -y
pre-commit install
pre-commit autoupdate
Run pre-commit with:
pre-commit run --all
Run the tests with:
bats test
If you want to run particular tests, you could use the test.sh
file:
chmod +x test.sh
./test.sh
bashcov bats test
- Include bash code coverage in GitLab CI.
- Add additional (relevant) pre-commit hooks.
- Develop Bash documentation checks here, and add them to this pre-commit.