projects/aports·blob master · refs

35 lines · 1.5 KiB

1Example: Connecting to remote postgresql
2========================================
3
4(1) On both the local & remote hosts:
5
6adduser -s /bin/false autossh <with blank passwords>
7-------------------------------------------------------------------
8
9(2) On the local client create an SSH key with an empty password:
10
11su -s /bin/sh autossh
12echo '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
19sleep 2
20exec 2>&1
21su -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------------------------------------------------------------------------------------------------------------------------------------------------------------
24ln -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
31psql -h 127.0.0.1 -p 1234 -U username -d database
32-------------------------------------------------------------------------------
33openssh-server: works out of the box | ed25519 keys possible
34dropbear: echo "/bin/false" >> /etc/shells | ecdsa keys possible
35tinyssh: port forwarding not yet implemented | ed25519 keys possible