Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
zh:docs:guide-quick-start:sshadministration [2020/10/14 01:40] – created guyezizh:docs:guide-quick-start:sshadministration [2024/12/02 08:12] – [首次 SSH 访问] starsfall
Line 1: Line 1:
 FIXME **This page is not fully translated, yet. Please help completing the translation.**\\ //(remove this paragraph once the translation is finished)// FIXME **This page is not fully translated, yet. Please help completing the translation.**\\ //(remove this paragraph once the translation is finished)//
  
-======SSH Access for Newcomers====== +======首次 SSH 访问======
-默认情况下,OpenWRT设备始终侦听端口22上的SSH命令行访问. 要通过SSH连接到您的路由器, 您需要在终端仿真器中输入命令 ''ssh root@192.168.1.1'' (对于路由地址 192.168.1.1).+
  
-第一次通过ssh访问路由器时,您可能会看到关于 //RSA key fingerprint// 的警告. 如果您确定这是OpenWrt设备的地址,只需键入 ''yes'' 然后按回车. 然后输入您给路由器的密码,如果这是初始设置,请按回车. 下面是一个会话示例:+管理OpenWrt的方法之一是在[[wp>SSH_(Secure_Shell)|SSH]]上使用[[docs:guide-user:base-system:user.beginner.cli|命令行界面]]。 
 +默认情况下,OpenWrt侦听端口“22/tcp”上的传入SSH连接。 
 +要“ssh进入路由器”,您可以使用路由器的LAN IP地址(通常为“192.168.1.1”)在终端模拟器中输入以下命令: 
 + 
 +<code bash> 
 +ssh root@192.168.1.1 
 +</code> 
 + 
 +第一次通过ssh访问路由器时,您可能会看到关于 //RSA key fingerprint// 的警告. 如果您确定这是 OpenWrt 设备的地址,只需键入 ''yes'' 然后按回车. 然后输入您给路由器的密码,如果这是初始设置,请按回车. 下面是一个会话示例:
 <code> <code>
 $ ssh root@192.168.1.1                                                    <== 你输入这个 $ ssh root@192.168.1.1                                                    <== 你输入这个
Line 28: Line 35:
  
 要结束与你路由器的 //ssh 会话// , 请键入 ''exit'', 然后按回车. 要结束与你路由器的 //ssh 会话// , 请键入 ''exit'', 然后按回车.
-本页的其余部分介绍了几种终端模拟器, 可用于Windows, Linux, 或 macOS 上访问OpenWrt设备+本页的其余部分介绍了几种终端模拟器, 可用于 Windows, Linux, 或 macOS 上访问 OpenWrt 设备.
-=====Windows Terminal Emulators===== +
-Windows 终端是 Windows 10 或较早传统的进程 (两者都可以访问Windows Powershell, Windows 命令提示符, WSL Bash), Putty, Cmder, Smartty, 以及 WinSCP 都是允许您通过SSH连接到OpenWrt路由器的终端模拟器.+
  
-====使用Windows 10内置终端====+====Windows终端模拟器 =====
  
-**Windows Powershell** and **命令提示符** 两者都使用 Windows 10 默认SSH 客户端. SSH 客户端是可windows功能, 必须启用,请阅读以下内容: [[https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse|Windows 10 上安装 OpenSSH ]]+可使用 Windows 终端或传统的 PowerShell、Command Prompt、ConHost 或 WSL Bash。PuTTY、MinGW(与 Git 一起安装)、Cmder、SmarTTY 和 WinSCP 等第三方程序也是可以提供 SSH 进入 OpenWrt 路由器终端模拟器。
  
-如果您已经安装了 WSL 发行版, SSH客户端通常会预装其中.+==== Windows 10/11 内置终端 ==== 
 +[[https://github.com/microsoft/terminal|Windows 终端]]、PowerShell 和命令提示符允许使用 SSH 客户端。该客户端现默认可用,但如果你的 Windows 版本较老,你可以按照本指南[[https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse|启用 SSH]]。
  
-如果你打开了 ''cmd.exe'', ''powershell.exe'' 或者 ''wsl.exe'' 传统的进程终端否则, 您可以从商店安装最新的 [[https://www.microsoft.com/store/productId/9N0DX20HK701|Windows Terminal]] 并从那里选择这些 shells 中的任何一个.+如果您已经安装了 [[https://docs.microsoft.com/en-us/windows/wsl/install|WSL 发行版]],SSH客户端通常会预装在其中。 
 + 
 +如果你打开了 ''cmd.exe'', ''powershell.exe'' 或者 ''wsl.exe'' 传统的 ConHost 终端就会打开。 否则, 您可以从商店安装最新的 [[https://www.microsoft.com/store/productId/9N0DX20HK701|Windows Terminal]] 并从那里选择这些 shells 中的任何一个.
   - 打开上述任何终端模拟器并输入 ''ssh root@192.168.1.1'' ("ssh" 是命令, "root" 是您要连接的OpenWrt用户, "192.168.1.1" 是 OpenWrt 默认 IP 地址)   - 打开上述任何终端模拟器并输入 ''ssh root@192.168.1.1'' ("ssh" 是命令, "root" 是您要连接的OpenWrt用户, "192.168.1.1" 是 OpenWrt 默认 IP 地址)
   - 将出现一条关于接受来自OpenWrt设备的新密钥的消息, 输入 "yes" 后并按回车.   - 将出现一条关于接受来自OpenWrt设备的新密钥的消息, 输入 "yes" 后并按回车.
Line 46: Line 54:
 Windows 10 可选的 SSH 特性还包括 SCP 客户端(通过SSH进入在OpenWrt中执行打开/编辑/下载/上传文件). 试试谷歌或度娘一些 SCP 教程来学习如何使用它. 否则, 使用 [[:docs:guide-quick-start:sshadministration#using_winscp|WinSCP]],这对 SCP 新手来说更容易. Windows 10 可选的 SSH 特性还包括 SCP 客户端(通过SSH进入在OpenWrt中执行打开/编辑/下载/上传文件). 试试谷歌或度娘一些 SCP 教程来学习如何使用它. 否则, 使用 [[:docs:guide-quick-start:sshadministration#using_winscp|WinSCP]],这对 SCP 新手来说更容易.
  
-====使用 Powershell 7====+==== Powershell ==== 
 +[[https://docs.microsoft.com/en-us/powershell/scripting/overview?view=powershell-7.2|Powershell]] 提供 SSH 访问。
  
-**Powershell 7** 提供SSH访问. 这里7.0版发布, 以及安装说明: https://devblogs.microsoft.com/powershell/announcing-PowerShell-7-0/+==== Windows Linux子系统(WSL) ==== 
 +Windows Linux子系统 在 Windows 上直接运行所选 Linux 环境(包括大多数命令行工具、实用程序和应用程序)便捷方法。有关如何在 Windows 10 上安装 WSL 的详细步骤,请参阅微软的文档:https://docs.microsoft.com/en-us/windows/wsl/install-win10
  
-====使用 putty==== +==== putty ==== 
-Putty给你命令行访问OpenWrt:+Putty提供命令行访问OpenWrt:
   - 从[[https://www.putty.org]]下载Putty: 只需可选从 ''Alternative binary files'' 部分选择下载32位或64位 ''putty.exe'' 二进制文件.   - 从[[https://www.putty.org]]下载Putty: 只需可选从 ''Alternative binary files'' 部分选择下载32位或64位 ''putty.exe'' 二进制文件.
   - 在你的Windows上打开 ''putty.exe'' -> 弹出Putty的登录窗口.   - 在你的Windows上打开 ''putty.exe'' -> 弹出Putty的登录窗口.
Line 58: Line 68:
   - 完成后,您将登录到OpenWrt命令行.   - 完成后,您将登录到OpenWrt命令行.
  
-====使用 WinSCP==== +基于密钥的身份验证。
-WinSCP allows you to browse the OpenWrt file system in Windows Exlorer like GUI-style: +
-  - Download WinSCP from [[https://winscp.net/eng/download.php]], get the non-beta ''Installation package'' or ''portable executables'' and install or unzip them on your Windows client +
-  - Start ''WinSCP.exe'' on your Windows client, WinSCP's login window will pop up +
-  - Click on ''New Site'' on the left, 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) +
-  - Click the ''Login'' at the bottom of the Window. +
-  - Done. You now have an Exlorer-like view of your OpenWrt filesystem.+
  
-**Editing OpenWrt config files with WINSCP's integrated GUI editor:**\\ +  - 使用 ''puttygen.exe''生成密钥对。 将私有密钥保存到本地计算机,并将公有密钥添加到您的 OpenWrt 设备的 ''/etc/dropbear/authorized_keys'' 文件中。 
-To edit a OpenWrt config file with WinSCP's GUI-based editor, just right-click the file in WinSCP and select ''Edit'' from the context menu.+  Connection → SSH → Auth:在“认证参数”下的“用于身份验证的私有密钥文件”框中,指定此连接所用的私有密钥文件路径(例如之前创建的 ''openwrt.ppk'' 文件)。最好点击“浏览...”,并通过文件对话框选择该文件。
  
-====Using Cmder==== +自动化连接。
-**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.+
  
-  - Download cmder from [[https://cmder.net/]] +  - Connection → Data:在“登录详情”框中输入自动登录用户名,该用户名为''root'' 
-  - Unzip the //cmder.zip// file +  - Loadsave 或者 删除存储的 session,在“Saved Sessions”中输入''openwrt.lan'',然后点击保存按钮。 
-  - Open the Cmder folderand double-click the {{:media:docs:howto:cmdericon.png?16|}} Cmder icon. You'll see a Cmder window open similar to the image below. +  - 要使用自动登录需要创建PuTTY快捷方式, 请创建一个并使用 ''@'' 符号附加保存的会话, 例如使用以下命令调用PuTTY: ''putty.exe @openwrt.lan''
-  - To ssh into the OpenWrt router at 192.168.1.1, type ''ssh root@192.168.1.1'' then press Return +
-{{:media:docs:howto:cmder.png?1592|}}+
  
-====Using Smartty==== +==== WinSCP ====
-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):+
  
-  Download Smartty from [[http://sysprogs.com/SmarTTY/]]: choose "download" for the installer, or "portable version" if you want it as a standalone program that works without installation. +WinSCP 有GUI界面像window文件管理一样浏览OpenWrt的文件系统。 
-  - after installation or after unzipping the archive, doubleclick on **SmarTTY** executable file. + 
-  - You will be greeted by a window with two choices, doubleclick on "setup a new SSH connection" (the other option is for serial connections, for usb-TTL dongles and somesuch you connect to the device's debug serial pins on the board, we won't use that now). +  - 下载 [[https://winscp.net/eng/download.php|WinSCP]],获取非 Beta 版 ''安装包'' or ''便携式可执行文件'' 并将其安装或解压到 Windows 上。 
-  - The window changes into the SSH setup, write the following info:  +  - 启动 ''WinSCP.exe'', WinSCP 的登录窗口将弹出。 
-    - **Host name:** OpenWrt device IP address (default is **192.168.1.1** ) +  - 点击左侧的「新建站点」,确保「文件协议」设置为 **scp**,然后在右侧将您的OpenWrt设备IP地址(192.168.1.1)输入到「主机名」中,默认端口保持为「22」。在「用户名」中输入 **root**,在「密码」中输入您的root **密码**(如果没有设置密码可以留空)。 
-    - **User Name:** **root** (this is the "administrator" and only user in default OpenWrt) +  - 点击窗口底部的登录。 
-    - **Password:** leave this blank for your first connection, then write the password you set up (either in Luci GUI or after your first SSH access) +  - 完成。 现在,您可以用类似 Exlorer 的方式查看 OpenWrt 文件系统了。 
-  - Click "Connect" button at the bottom, and you will now see a big terminal screen coming up + 
-  - A default OpenWrt firmware lacks the server component to allow you to open/edit/view/upoad/download files in Smartty, so after you have connected to the internet write  ''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. +使用 WinSCP 集成的 GUI 编辑器编辑 OpenWrt 配置文件。 
-  - Now you can click on **File -> Open a Remote File** to open a popup that shows the filesystem of the OpenWrt device, and you can navigate in it and open text files for example as normal (they will open in a SmarTTY text editor window)+ 
 +  - 要使用 WinSCP 基于 GUI 的编辑器编辑 OpenWrt 配置文件,只需右键单击 WinSCP 中的文件,然后从上下文菜单中选择 ''编辑''。 
 + 
 +==== Cmder ==== 
 + 
 +Cmder for Windows 是一个开源、运行在Windows系统的终端模拟器 
 +它免费使用,并提供了一个易于操作的“命令行外壳”,允许您通过ssh连接到OpenWrt。 
 +其吸引人的字体和配色方案对眼睛很友好。 
 +推荐使用 //Full// 版本(而非 //mini// 版本),因为它提供了bash模拟环境,包含了一系列Unix风格的命令。 
 + 
 +  - 下载 [[https://cmder.net/|Cmder]] 
 +  - 解压 //cmder.zip//  
 +  - 打开Cmder文件夹,然后双击Cmder图标。你会看到一个类似下面图片的Cmder窗口弹出。 
 +  - 要通过SSH连接到IP地址为192.168.1.1的OpenWrt路由器,请输入 ``ssh root@192.168.1.1``,然后按回车键。 
 + 
 +==== SmarTTY ==== 
 +SmarTTY让您可以通过命令行访问OpenWrt,并允许您在OpenWrt中打开/编辑/下载/上传文件,并且总体上比PuTTY(下文详述的另一个工具)更现代和用户友好。 
 + 
 +  下载 [[http://sysprogs.com/SmarTTY/|SmarTTY]] 安装程序,如果您希望它作为无需安装即可运行,请选择“便携式版本”。 
 +  - 安装完成后或解压后,双击执行名为**SmarTTY**的可执行文件。 
 +  - 你会看到一个窗口,有两个选择,双击“设置一个新的SSH连接”(另一个选项是串行连接,对于usb-TTL加密狗和一些你连接到板上设备调试串行引脚的东西,我们现在不会使用它)。 
 +  - 窗口更改为SSH设置,请写入以下信息: 
 +    - **Host name:** OpenWrt设备IP地址 (默认为 **192.168.1.1** ) 
 +    - **User Name:** **root** (这是默认OpenWrt中的“管理员”和唯一用户
 +    - **Password:** 为您的第一次连接留空,然后写下您设置的密码(在Luci GUI中或在您第一次SSH访问后) 
 +  - 单击底部的“连接”按钮,您现在将看到一个大的终端屏幕出现 
 +  - A default OpenWrt firmware lacks the server component to allow you to open/edit/view/upoad/download files in SmarTTY, so after you have connected to the internet write ''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. 
 +  - Now you can click on **File -> Open a Remote File** to open a popup that shows the file system of the OpenWrt device, and you can navigate in it and open text files for example as normal (they will open in a SmarTTY text editor window)
   - If you want to upload or download files to/from a specific folder in the device, you can click on SCP menu and choose the most appropriate action from there.   - If you want to upload or download files to/from a specific folder in the device, you can click on SCP menu and choose the most appropriate action from there.
  
-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.+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.
  
-=====Linux Terminal Emulators=====+===== Linux terminal emulators =====
 All Linux distributions provide a command-line ssh client as part of the default installation. All Linux distributions provide a command-line ssh client as part of the default installation.
  
Line 103: Line 131:
   - if you want to close the session, write "exit"   - if you want to close the session, write "exit"
  
-Linux also usually has SCP 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" to find where it is and its current installation status. +Linux also usually has SCP/SFTP clients (to open/edit/download/upload files in OpenWrt), which may or may not be installed by default. 
-Read its integrated manual ("man scp" for example is for the command line SCP clientor google some tutorials to learn how to use it.+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 [[man>scp|scp manual]] for the command line SCP client or google some tutorials to learn how to use it. 
 + 
 +==== Midnight Commander ==== 
 +[[https://midnight-commander.org/|Midnight Commander]] is Norton Commander like file manager that works on Linux and macOS. 
 +You can access remote files on OpenWrt via mc: 
 + 
 +  - Press 'F9' 
 +  - Select 'Left' panel config 
 +  - Select 'Shell link' 
 +  - Input 'root@192.168.1.1/' and press OK 
 +  - Now you'll see list of files and directories in root of OpenWrt 
 + 
 +Internally it works over [[wp>Files_transferred_over_shell_protocol|scp like protocol FISH]] so it not needs for installed SFTP server. 
 + 
 +===== macOS terminal emulators ===== 
 +On macOS (formerly Mac OSX) any terminal emulator will allow you to ssh. 
 + 
 +  - Terminal - 内置的终端程序,可在 /Applications/Utilities 中找到。 
 +  - [[https://iterm2.com/|iTerm2]] 是一款功能更强大的终端程序,捐赠软件,值得购买。
  
-=====macOS Terminal Emulators ===== +要 ssh 进入位于 192.168.1.1 的 OpenWrt 路由器,请键入 ''ssh root@192.168.1.1'',然后按 Return 键。
-On macOS (formerly Mac OSX) any terminal emulator will allow you to ssh. There several terminal emulators:+
  
-  - Terminal - The macOS built-in terminal program. Find it in /Applications/Utilities  +===== ChromeOS terminal emulator ===== 
-  - iTerm2 [[https://iterm2.com/]] a much-enhanced terminal program. Donation-ware - it's worth it.+在 [[wp>ChromeOS]] 上, [[https://chrome.google.com/webstore/detail/secure-shell/iodihamcpbpeioajjeobimgagajmlibd|安全外壳 (SSH)]] 可以让你使用 SSH。
  
-To ssh into your OpenWrt router at 192.168.1.1, type ''ssh root@192.168.1.1'', then press Return.  
  • Last modified: 2024/12/02 10:17
  • by starsfall