LoginSignup
13
10

OpenWrt 新規設定用 オールインワンスクリプト Windowsから導入 初心者対応

Last updated at Posted at 2023-08-26

:warning:Japanese notation

はじめに

初心者対応構成

  • スクリプトでの自動設定
  • UCIとLuCi及びWinSCPにて比較しながら作業がおススメ

前提条件

新規設定用 オールインワンスクリプト 初心者対応

不具合あればご連絡下さい

スクリプトセレクター

config.png

構成
スクリプト

PowerShellSSHアクセス

ssh root@192.168.1.1
ssh root@192.168.1.1のショートカット作成(デスクトップ)
powershell
$DESKTOP = ([Environment]::GetFolderPath("Desktop") + "\192.168.1.1.lnk")
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$DESKTOP")
$Shortcut.TargetPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
$Shortcut.Arguments = '-windowstyle hidden -ExecutionPolicy RemoteSigned "Start-Process ssh root@192.168.1.1"'
$Shortcut.IconLocation = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe,0"
$Shortcut.WorkingDirectory = "."
$Shortcut.Save()

  • 強制的に貼り付け
  • yes

SSHログイン出来ない場合:exclamation:

known_hostsクリア

  • C:\Users\yourusername\.ssh\known_hosts ※Windows隠しファイル
powershell
Clear-Content .ssh\known_hosts -Force


OpenSSHのインストール
※Windows 10 Fall Creators Update(1709)以降標準搭載

  • 機能の確認
powershell
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

  • 機能のインストール
powershell
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0


ttydのインストールと設定

ttyd.sh
容量:約2MB

:warning:インターネット接続設定はデバイスをONUに直接接続する事

mkdir -p /etc/config-software; wget --no-check-certificate -O /etc/config-software/ttyd.sh https://raw.githubusercontent.com/site-u2023/config-software/main/ttyd.sh; sh /etc/config-software/ttyd.sh

MAP-eなど未設定でIPv4不通の場合:exclamation:

https://github.com/ はIPv6利用で接続可

  • 設定用クライアントをLAN1に接続
ssh
# IPv6利用設定
uci add network device
uci set network.@device[-1].name='lan1'
uci set network.@device[-1].mtu='1500'
uci set network.@device[-1].ipv6='1'
uci set network.@device[-1].mtu6='1500'
#
uci commit network
/etc/init.d/network reload


スクリプトセレクターの実行

LAN側からのみ許可
ログイン認証無し
※ttydの設定から変更可

confsoft

:warning:強制終了:Ctrl+c

削除

rm -rf /etc/config-software
rm -rf /usr/bin/confsoft

アクセス

LuCi

  • ブラウザから実行:
    openwrt.lan (192.168.1.1)

    • ユーザー名:root
    • パスワード:設定したパスワード
  • QRコードから実行:
    192.168.1.1
    QR192.168.1.1.png

TTYD

SFTP

ファイラー(WinSCPでエクスプローラー風に利用)
※要WinSCPインストール

  • ダウンロード:WinSCP

  • WinSCPを起動

    • セッション
      • ホスト名:192.168.1.1
      • ユーザー名:root
      • パスワード:設定したパスワード
      • ログインをクリック

初期化

ファクトリーリセット(初期化)

# 要注意
firstboot && reboot now

This will erase all settings and remove any installed packages. Are you sure? [N/y]

  • y

デバイスリセットボタン

デバイスのリセットボタンを5秒押し続ける

メインページ

GitHub

github.com/site-u2023

あとがき

面白くなって色々ワンコピペに組み込んでみました

参考資料(感謝:relaxed:

13
10
27

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
13
10