Autosshを起動時に実行するように設定して/etc/rc.localに追加しようとしましたが、バックグラウンドで実行することすらできません。
これは私の設定ファイルの重要な部分です:
Host remotehost.com
LocalForward 127.0.0.1:8082 127.0.0.1:8082
LocalForward 127.0.0.1:8000 127.0.0.1:80
LocalForward 127.0.0.1:10001 127.0.0.1:10001
LocalForward 127.0.0.1:12001 127.0.0.1:12001
Port 9922
このコマンドは機能します:
autossh -F /home/[username]/.ssh/config -i /home/[username]/.ssh/id_rsa remotehost.com
しかし、-fオプションを追加すると
autossh -f -F /home/[username]/.ssh/config -i /home/[username]/.ssh/id_rsa remotehost.com
そうではありません。
ご覧のとおり、私は絶対パスのみを使用しているので、 この問題 であってはなりません。
これは私のログが言っていることです:
2014/04/22 12:09:07 autossh[4367]: checking for grace period, tries = 0
2014/04/22 12:09:07 autossh[4367]: starting ssh (count 1)
2014/04/22 12:09:07 autossh[4367]: ssh child pid is 4368
2014/04/22 12:09:07 autossh[4367]: check on child 4368
2014/04/22 12:09:07 autossh[4367]: set alarm for 600 secs
2014/04/22 12:09:07 autossh[4368]: execing /usr/bin/ssh
2014/04/22 12:09:07 autossh[4367]: check on child 4368
2014/04/22 12:09:07 autossh[4367]: ssh exited with status 0; autossh exiting
2014/04/22 12:09:07 autossh[4367]: expired child, returning 2
ああ。愚かな私。私はそれを逃したが、これはマニュアルでカバーされています。 -N
-スイッチを追加する必要がありました。これは私がrc.localに入れたもので、機能します。
su [username] -c 'autossh -f -N -F /home/[username]/.ssh/config_tunnels -i /home/[username]/.ssh/id_rsa remotehost.com
[username]
はもちろん私のユーザー名と交換されます。