This page is not fully translated, yet. Please help completing the translation.
(remove this paragraph once the translation is finished)
默认情况下,OpenWrt 设备始终侦听端口22/tcp
上的SSH命令行访问。
要通过SSH连接到您的路由器, 您需要在终端仿真器中输入以下命令(对于路由地址 192.168.1.1):
ssh root@192.168.1.1
第一次通过ssh访问路由器时,您可能会看到关于 RSA key fingerprint 的警告. 如果您确定这是 OpenWrt 设备的地址,只需键入 yes
然后按回车. 然后输入您给路由器的密码,如果这是初始设置,请按回车. 下面是一个会话示例:
$ ssh root@192.168.1.1 <== 你输入这个 The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established. RSA key fingerprint is SHA256:4VbDA/MOc7inPiyllF5f0r3Q6iEx89ddKdhLGBovsiY. Are you sure you want to continue connecting (yes/no)? yes <== 和这个 Warning: Permanently added '192.168.1.1' (RSA) to the list of known hosts. root@192.168.1.1's password: <== 这里输入密码 BusyBox v1.28.4 () built-in shell (ash) _______ ________ __ | |.-----.-----.-----.| | | |.----.| |_ | - || _ | -__| || | | || _|| _| |_______|| __|_____|__|__||________||__| |____| |__| W I R E L E S S F R E E D O M ----------------------------------------------------- OpenWrt 18.06.2, r7676-cddd7b4c77 ----------------------------------------------------- root@OpenWrt:~# <== 在此处键入下一个命令
要结束与你路由器的 ssh 会话 , 请键入 exit
, 然后按回车.
本页的其余部分介绍了几种终端模拟器, 可用于 Windows, Linux, 或 macOS 上访问 OpenWrt 设备.
可使用 Windows 终端或传统的 PowerShell、Command Prompt、ConHost 或 WSL Bash。PuTTY、MinGW(与 Git 一起安装)、Cmder、SmarTTY 和 WinSCP 等第三方程序也是可以提供 SSH 进入 OpenWrt 路由器的终端模拟器。
Windows 终端、PowerShell 和命令提示符允许使用 SSH 客户端。该客户端现在默认可用,但如果你的 Windows 版本较老,你可以按照本指南启用 SSH。
如果您已经安装了 WSL 发行版,SSH客户端通常会预装在其中。
如果你打开了 cmd.exe
, powershell.exe
或者 wsl.exe
,传统的 ConHost 终端就会打开。 否则, 您可以从商店安装最新的 Windows Terminal 并从那里选择这些 shells 中的任何一个.
ssh root@192.168.1.1
(“ssh” 是命令, “root” 是您要连接的OpenWrt用户, “192.168.1.1” 是 OpenWrt 默认 IP 地址)Windows 10 可选的 SSH 特性还包括 SCP 客户端(通过SSH进入在OpenWrt中执行打开/编辑/下载/上传文件). 试试谷歌或度娘一些 SCP 教程来学习如何使用它. 否则, 使用 WinSCP,这对 SCP 新手来说更容易.
Powershell 提供 SSH 访问。
Windows Subsystem for Linux 是在 Windows 上直接运行所选 Linux 环境(包括大多数命令行工具、实用程序和应用程序)的便捷方法。有关如何在 Windows 10 上安装 WSL 的详细步骤,请参阅微软的文档:https://docs.microsoft.com/en-us/windows/wsl/install-win10
Putty给你命令行访问OpenWrt:
putty.exe
→ 弹出Putty的登录窗口.Session
类别, 在右侧 Host Name (or IP address)
下的文本框输入OpenWrt设备的IP地址 (e.g. 192.168.1.1) , 保留默认提供的端口 22.Open
按钮打开连接. 这将弹出一个shell窗口, 正在请求 login as
. 使用您以前定义的OpenWrt密码作为 root 登录. 如果您尚未在 “root” 上设置密码, 则不会要求您输入密码.Setting up key-based authentication.
puttygen.exe
. Save the private key to the PC and add the public key to /etc/dropbear/authorized_keys
on your OpenWrt device.openwrt.ppk
file you created before). Best is to click “Browse...” and select the file via the file dialog.Automating connections.
root
.openwrt.lan
in Saved Sessions and click the Save button.@
sign, for example call PuTTY with: putty.exe @openwrt.lan
WinSCP allows you to browse the OpenWrt file system in Windows Exlorer like GUI-style.
WinSCP.exe
, WinSCP 的登录窗口将弹出。New Site
on the left, ensure File protocol
is set to scp then enter your OpenWrt device IP address (192.168.1.1) on the right side into Host name
, keep the default port 22
. In User name
enter root, in Password
, enter your root password (or leave blank, if you have not set a password yet)使用 WinSCP 集成的 GUI 编辑器编辑 OpenWrt 配置文件。
编辑
。Cmder for Windows is an open-source terminal emulator that runs on Windows. It is free to use and provides an easy “command line shell” that allows you to ssh into OpenWrt. Its attractive fonts and color scheme are easy on the eyes. The Full distribution is preferred (over the mini distribution), since it provides a bash emulation, with a Unix-y suite of commands.
ssh root@192.168.1.1
then press Return.SmarTTY gives you command line access to OpenWrt and allows you to open/edit/download/upload files in OpenWrt, and is overall more modern and user-friendly than PuTTY (another tool detailed below).
opkg update && opkg install openssh-sftp-server
to install it. If the next step fails, it might be necessary to reboot the OpenWrt device for this new service to start up properly.After the first time you connected to a device, SmarTTY saved a profile, so you can connect again to the same device (at that IP address with that password) by just doubleclicking its icon on the first window you see when starting SmarTTY. You can right-click on this profile icon to edit it again, if needed.
All Linux distributions provide a command-line ssh client as part of the default installation.
ssh root@192.168.1.1
(“ssh” is the command, “root” is the OpenWrt user you are connecting to, and “192.168.1.1” is OpenWrt default IP)Linux also usually has SCP/SFTP clients (to open/edit/download/upload files in OpenWrt), which may or may not be installed by default. You need to look up your distro's documentation or search with your package management interface for “scp” and “sftp” to find where it is and its current installation status. Read scp manual for the command line SCP client or google some tutorials to learn how to use it.
Midnight Commander is Norton Commander like file manager that works on Linux and macOS. You can access remote files on OpenWrt via mc:
Internally it works over scp like protocol FISH so it not needs for installed SFTP server.
On macOS (formerly Mac OSX) any terminal emulator will allow you to ssh.
要 ssh 进入位于 192.168.1.1 的 OpenWrt 路由器,请键入 ssh root@192.168.1.1
,然后按 Return 键。
在 ChromeOS 上, 安全外壳 (SSH) 可以让你使用 SSH。