0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

WSLからSSH先のRSSリーダーのブラウザで開くを手元のFirefoxで開く

Last updated at Posted at 2022-08-18

ezgif.com-gif-maker.gif

TL;DR

以前に通知ロジックを実装した.

現在リモートの「mysrv」で色々作業しているが,ニュースみるとき,ブラウザ操作がめんどくさい.そこで,CLIのRSSリーダーである「newsboat」を入れたが,ウェブブラウザで見たいときにすぐ開けないと困る.

なので,リモートのLinux環境のリクエストに対し,手元で開くようにした.

wsl-revshell-server.sh

スクリプトの大体のロジックは通知ロジックと同じ.アイコンの設定やアラームの設定箇所を消してそのままPowershell上で実行するように変更した.

今回は,特異箇所だけピックアップする.

  1. powershellで実行する際はstart https://www.example.com のように送ればデフォルトブラウザ(i.e. Firefox in me)で開かれる.
  2. Port番号: 通知用のポートが47123なので,今回は47124 を利用した.
  3. sshコマンドのエイリアスについて

3. sshコマンドのエイリアス

前回は単純に,

# sshするときにプロキシ張る
alias ssh='ssh -R ${WSL_NOTIF_PORT}:localhost:${WSL_NOTIF_PORT}'

と実装した.これだと,47124が使えないので,

export SSH_OPTS="-R ${WSL_REVSH_PORT}:localhost:${WSL_REVSH_PORT} $SSH_OPTS"
alias ssh="ssh $SSH_OPTS"

とし,前回の実装は

diff --git a/custom-available.d/wsl-notification-server.sh b/custom-available.d/wsl-notification-server.sh
index b3b4d07..780b87a 100644
--- a/custom-available.d/wsl-notification-server.sh
+++ b/custom-available.d/wsl-notification-server.sh
@@ -100,4 +100,5 @@ wslnotify() {
   fi
   echo "$sound $text" | nc -w1 127.0.0.1 "$WSL_NOTIF_PORT"
 }
-alias ssh='ssh -R ${WSL_NOTIF_PORT}:localhost:${WSL_NOTIF_PORT}'
+export SSH_OPTS='-R ${WSL_NOTIF_PORT}:localhost:${WSL_NOTIF_PORT}'"$SSH_OPTS"
+alias ssh='ssh -R ${SSH_OPTS}'

こんな感じに変更.

リモート側の設定

ブラウザの起動コマンド

~/.local/bin/www-browser として下記のようなスクリプトを放り込んだ.

#!/bin/bash
echo "start $@" | nc 127.0.0.1 47124 2>/dev/null

newsboatの設定

newsboatでブラウザ指定.

~/.newsboat/config

browser "~/.local/bin/www-browser %u"

上記で快適にRSSを読むことができそうだ.

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?