0
0

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 3 years have passed since last update.

WSL2のsshdに他のPCからssh接続

Posted at
start-sshd.bat
# sshdの起動
wsl -u root -- service ssh start

# ポートフォワーディング設定
wsl -u root -- sh /opt/bin/port_forwarding.sh
/opt/bin/port_forwarding.sh
# !/bin/bash

set -eux

IP=$(hostname -I)

# netsh.exe interface portproxy delete v4tov4 listenport=22
netsh.exe interface portproxy add    v4tov4 listenport=22 connectaddress=$IP

sc.exe config iphlpsvc start=auto
sc.exe start  iphlpsvc

管理者権限で実行させるショートカット登録

管理者権限で実行させる必要がある。
start-sshd.batのショートカットを作成し、管理者として実行にチェックを入れる。

Untitled.png

起動方法

スタートアップに入れても管理者権限で実行してくれなかったので
手動でダブルクリック。

タスクスケジューラに登録という方法がおすすめみたいなので必要に応じて登録。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?