A script (that needs some work) that documents for me how to setup and launch an autossh session to a cloud server. Not really useful for others.
If you want to setup your own server though the steps are: Create the remote cloud server autossh account (Only need to do this once)
useradd -m -s /bin/false autossh
mkdir ~autossh/.ssh && chmod 700 ~autossh/.ssh
touch ~autossh/.ssh/authorized_keys && chmod 600 ~autossh/.ssh/authorized_keys
chown -R autossh.autossh ~autossh/.ssh
For eachbox you want autossh installed onto steps:
curl https://gist.githubusercontent.com/dayne/5653f864a3de06f238648cb087597512/raw/setup-autossh.sh | bash
or
curl https://git.io/fpwsk | bash
After running that you need to do the following steps:
- Add the
~/.ssh/id_rsa-autossh.pub
key toautossh@cloud_server:.ssh/authorized_keys
curl --upload-file $HOME/.ssh/id_rsa-autossh.pub https://transfer.sh/pubkey.txt
can help copy-n-paste if needed
- Ensure the cloud server ssh key is known to the user account
ssh cloud_server
and accept the key- or I should upgrade:
ssh-keyscan -H n1nj4.net > ~/.ssh/known_hosts ssh-keyscan -H `host n1nj4.net | awk '{print $NF}'` > ~/.ssh/known_hosts
- Modify
~/.local/autossh-on-reboot.sh
to use the proper name of cloud_server (or setup the below .ssh/config line)vi ~/.local/autossh-on-reboot.cfg
and set any vairables needed for configuration - at minimum you likely need to set `CLOUD_S
- Test it out
Here is an example of how to setup your workstation to be able to type ssh remote_box
and have that session proxy jump through cloud_server and through the autossh tunnel.
Host cloud_server
Hostname 1.2.3.4
User ubuntu
Host remote_box
User pi
Hostname localhost
Port 50322
ProxyJump cloud_server