| 1 | Example: Connecting to remote postgresql |
| 2 | ======================================== |
| 3 | |
| 4 | (1) On both the local & remote hosts: |
| 5 | |
| 6 | adduser -s /bin/false autossh <with blank passwords> |
| 7 | ------------------------------------------------------------------- |
| 8 | |
| 9 | (2) On the local client create an SSH key with an empty password: |
| 10 | |
| 11 | su -s /bin/sh autossh |
| 12 | echo 'y' |ssh-keygen -t ed25519 -N '' |
| 13 | ------------------------------------------------------------------- |
| 14 | |
| 15 | (3) If using runit for service supervision < /etc/sv/autossh/run >: |
| 16 | |
| 17 | ------------------------------------------------------------------- |
| 18 | #!/bin/sh |
| 19 | sleep 2 |
| 20 | exec 2>&1 |
| 21 | su -s /bin/sh autossh -c \ |
| 22 | 'export AUTOSSH_GATETIME=0 && nohup autossh -M 0 -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -L 1234:localhost:1234 -N -l autossh remote.ip.addr' |
| 23 | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 24 | ln -s /etc/sv/autossh /etc/service/autossh |
| 25 | ------------------------------------------------------------------------------- |
| 26 | ** if running autossh in a script without using runit add -f to ssh options **| |
| 27 | ------------------------------------------------------------------------------- |
| 28 | |
| 29 | (4) Connect with: |
| 30 | |
| 31 | psql -h 127.0.0.1 -p 1234 -U username -d database |
| 32 | ------------------------------------------------------------------------------- |
| 33 | openssh-server: works out of the box | ed25519 keys possible |
| 34 | dropbear: echo "/bin/false" >> /etc/shells | ecdsa keys possible |
| 35 | tinyssh: port forwarding not yet implemented | ed25519 keys possible |