Skip to content

Commit

Permalink
Allow to set any SSH options
Browse files Browse the repository at this point in the history
  • Loading branch information
stephdewit committed Dec 28, 2017
1 parent e369c7c commit 96a6ba5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Role Variables
- `autossh_port`: TCP port to connect to.
- `autossh_login`: Username used to authenticate on remote server.
- `autossh_hostkey`: Host key of the remote server.
- `autossh_local_forwards`: Local port forwards to remote localhost. Written as `<local_port>:<remote_port>` and separated by spaces.
- `autossh_options`: Parameters added to the SSH command line, e.g. for port forwarding.

An `autossh_public_keys` fact is set and contains a dictionary, indexed by the `autossh_name` value, with every public key.

Expand All @@ -36,7 +36,7 @@ Example Playbook
autossh_port: 2222
autossh_login: me
autossh_hostkey: [app01.example.com]:2222,[1.2.3.4]:2222 ssh-rsa AAAA1234.....=
autossh_local_forwards: 3000:3000 3010:3010 4000:4000
autossh_options: -L 3000:localhost:3000 -L 3010:localhost:3010

License
-------
Expand Down
7 changes: 1 addition & 6 deletions files/initscript.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ start() {
mkdir -p /run/autossh /var/log/autossh
chown autossh:autossh /run/autossh /var/log/autossh

forwards=''
for forward in $LOCALFORWARDS; do
forwards="$forwards -L $(echo $forward | sed 's/:/:localhost:/')"
done

export AUTOSSH_PIDFILE
export AUTOSSH_LOGFILE

Expand All @@ -31,7 +26,7 @@ start() {
-l $LOGIN \
$HOST -p $PORT \
-i /home/autossh/.ssh/$servername \
$forwards
$OPTIONS
eend $?
}

Expand Down
2 changes: 1 addition & 1 deletion templates/configuration.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HOST={{ autossh_host }}
PORT={{ autossh_port }}
LOGIN={{ autossh_login }}
LOCALFORWARDS="{{ autossh_local_forwards }}"
OPTIONS="{{ autossh_options }}"

0 comments on commit 96a6ba5

Please sign in to comment.