WinSCP和PuTTY在刷openwrt固件的使用教程

【openwrt必备工具】WinSCP和PuTTY的搭配与使用

PuTTY和WinSCP是管理OpenWRT固件的路由器必备工具。

WinSCP的优势在于支持多语言、可在图形化界面下管理Linux系统里的文件和存储多个会话设置以方便多设备多用户登录。PuTTY的优势在于提供与Linux终端一样的命令行控制界面。

所以,一般可先用WinSCP登录,管理文件,在必要的时候,调出PuTTY输入终端命令,实现优势互补。那既然在WinSCP中快速调用PuTTY输入终端命令是常见的事,就得让二者更好的配合,方法如下:

1.下载免安装版的WinSCP,解压至XXX\WinSCP目录(XXX表示某一个目录);
2.下载需要的语言包,解压至XXX\WinSCP目录;
3.下载免安装版的PuTTY,解压至XXX\PuTTY;
4.运行XXX\WinSCP\WinSCP.exe,出现“WinSCP登录”窗口;
5.按下“Languages”按钮,选择语言;
6.勾选“高级选项”;
7.选择树状列表中的“选项”项目;
8.按下“其它通用选项”的“选项”按钮,弹出的“选项”窗口;
9.选择“选项”窗口里树状列表中的“集成-应用程序”;
10.把“PuTTY路径”改为相对路径的“..\PuTTY\putty.exe”(这一步是关键,路径前面的“..”表示父目录,即代表上面“XXX”目录,改成这样的好处是以后只要把XXX目录下的WinSCP和PuTTY两个目录一起移动到其它任意一个目录后,这个设置依然有效);
11.勾选“记住会话密码并传给PuTTY(SSH)”项目,点“确定”按钮返回“WinSCP登录”窗口;
12.选择树状列表中的“会话”项目;
13.在“文件协议”下拉列表框中选择“SCP”;
14.在“主机名”文本框中输入“192.168.99.1”(如意·云路由默认的IP地址);
15.在“端口号”文本框中输入“22”(OpenWRT SSH服务默认的端口);
16.在“用户名”文本框中输入“root”(OpenWRT默认的管理员账户名);
17.在“密码”文本框中输入管理员账户的密码;
18.点“保存”按钮,弹出“会话另存为”窗口;
19.在“会话另存为”文本框中输入会话名称,点“确定”按钮返回“WinSCP登录”窗口;
20.在选择树状列表中的“会话-存储的会话”项目;
21.选择会话名称,点“登录”按钮,弹出“警告”窗口;
22.按“否”按钮,弹出“WinSCP”主界面,左侧是本地目录,右侧是路由器的Linux系统目录;
23.可以在本地目录和路由器Linux系统目录间拖拽文件完成文件复制传输,在路由器的Linux系统目录的文件上按双击可以打开文件,按“Ctrl+P”快捷键(或按“命令”主菜单-“在PuTTY中打开”),弹出“PuTTY Security Alert”窗口,按“否”键钮,可直接打开PuTTY窗口并自动登录路由器的Linux终端。

刷固件:

1.1 Root无密码时: 可用HFS构建HTTP文件服务器. 如:http://192.168.1.224/wr703n-eok.bin, 然后CMD命令窗口中输入命令:
telnet 192.168.1.1
cd /tmp
wget http://192.168.1.224/wr703n-eok.bin
1.2 Root有密码时: 先将固件用winscp上传到/tmp/下或者用上面的wget命令, 然后用putty或者securecrt登陆路由器
2. mtd -r write /tmp/固件.bin firmware, 成功后会出现 rebooting…
注: dd下用 linux,openwrt下用 firmware

— mtd 源码中的相关部分:

static void usage(void)
{
    fprintf(stderr, "Usage: mtd [<options> ...] <command></command> [<arguments> ...] <device>[:<device>...]\n\n"
    "The device is in the format of mtdX (eg: mtd4) or its label.\n"
    "mtd recognizes these commands:\n"
    "        unlock                  unlock the device\n"
    "        refresh                 refresh mtd partition\n"
    "        erase                   erase all data on device\n"
    "        write <imagefile>|-     write <imagefile> (use - for stdin) to device\n"
    "        jffs2write <file>       append <file> to the jffs2 partition on the device\n");
    if (mtd_fixtrx) {
        fprintf(stderr,
    "        fixtrx                  fix the checksum in a trx header on first boot\n");
    }
    fprintf(stderr,
    "Following options are available:\n"
    "        -q                      quiet mode (once: no [w] on writing,\n"
    "                                           twice: no status messages)\n"
    "        -n                      write without first erasing the blocks\n"
    "        -r                      reboot after successful command\n"
    "        -f                      force write without trx checks\n"
    "        -e <device>             erase <device> before executing the command\n"
    "        -d <name>               directory for jffs2write, defaults to \"tmp\"\n"
    "        -j <name>               integrate <file> into jffs2 data when writing an image\n");
    if (mtd_fixtrx) {
        fprintf(stderr,
    "        -o offset               offset of the image header in the partition(for fixtrx)\n");
    }
    fprintf(stderr,
#ifdef FIS_SUPPORT
    "        -F <part>[:<size>[:<entrypoint>]][,<part>...]\n"
    "                                alter the fis partition table to create new partitions replacing\n"
    "                                the partitions provided as argument to the write command\n"
    "                                (only valid together with the write command)\n"
#endif
    "\n"
    "Example: To write linux.trx to mtd4 labeled as linux and reboot afterwards\n"
    "         mtd -r write linux.trx linux\n\n");
    exit(1);
}</part></entrypoint></size></part></file></name></name></device></device></file></file></imagefile></imagefile></device></device></arguments></options>

Opkg 是一个轻量快速的套件管理系统,目前已成为 Opensource 界嵌入式系统标准。
常用于路由、交换机等嵌入式设备中,用来管理软件包的安装升级与下载。常用命令如下:
opkg update 更新可以获取的软件包列表
opkg upgrade 对已经安装的软件包升级
opkg install 安装指定的软件包
opkg instal /tmp/xxx.ipk
opkg install http://openwrt.8800.org:82/nwan.ipk
opkg install http://openwrt.8800.org/luci-app-nwan.ipk
opkg install –force-reinstall http://192.168.1.224/uhttpd_32_ar71xx.ipk
opkg remove 卸载已经安装的指定的软件包. opkg remove luci-i18n-chinese
opkg list
opkg list-installed

Force Options:
–force-depends Install/remove despite failed dependencies
–force-maintainer Overwrite preexisting config files
–force-reinstall Reinstall package(s)
–force-overwrite Overwrite files from other package(s)
–force-downgrade Allow opkg to downgrade packages
–force-space Disable free space checks
–force-postinstall Run postinstall scripts even in offline mode
–force-remove Remove package even if prerm script fails
–noaction No action – test only
–download-only No action – download only
–nodeps Do not follow dependencies
–force-removal-of-dependent-packages
Remove package and all dependencies
–autoremove Remove packages that were installed
automatically to satisfy dependencies
-t Specify tmp-dir.
–tmp-dir Specify tmp-dir.

一般我们在openwrt下用opkg安装软件有两种:
1. 连上网络后从官方网站安装 opkg update; opkg install XXX.ipk;
opkg install http://openwrt.8800.org/luci-app-nwan.ipk
2. PC上把软件下载下来,传到路由器tmp目录安装 opkg install /tmp/XXX.ipk

对于1来说,如果路由暂时上不了网,就无法使用,方法2又有些麻烦. 这里提供的方法是:
1. 修改/etc/opkg.conf, 把里边第一行那个网址改成本地服务器放安装包的服务目录,
#src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages
src/gz snapshots http://192.168.1.224/packages-r31296
2. 把相关的 packages 目录下的文件都放在上步定义的目录下(packages-r31296为目录名)
3. 在本机上用 HTS 开启http服务, 添加上面的目录
4. 现在可以像方法1一样使用升级了

工作图片如下:
这里写图片描述

版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://www.cnblogs.com/yangquanhui/p/4937499.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
openwrt命令行模式命令及其工具 需要学会用ssh登录路由器用linux命令查看。 ps 命令查看当前系统运行的进程信息 free 命令查看内存使用和swap挂载情况 ls 查看目录和文件 cd 进入退出目录 vi 查看编辑配置文件 安装命令: #opkg update #opkg install nano uci set network.lan.ipaddr=[lan ip] 使用pppoe设置 Shell代码 uci set network.wan.proto=pppoe //设置wan口类型为pppoe uci set network.wan.username=[上网帐户] uci set network.wan.password=[上网密码] //这两行设置pppoe用户名和密码 如果要挂在上级路由下面,就需要进行下面的设置 Shell代码 uci set network.wan.proto=none //关掉wan uci set network.lan.gateway=[上级路由ip] //网关指向上级路由 uci set network.lan.dns=[上级路由ip] //dns指向上级路由 uci set dhcp.lan.ignore=1 //关掉lan的dhcp 最后对无线网络进行配置 Shell代码 uci set wireless.@wifi-device[0].disabled=0 //打开无线 uci set wireless.@wifi-device[0].txpower=17 //设置功率为17dbm 太高会烧无线模块 uci set wireless.@wifi-device[0].channel=6 //设置无线信道为6 uci set wireless.@wifi-iface[0].mode=ap //设置无线模式为ap uci set wireless.@wifi-iface[0].ssid=[自己设置SSID] //设置无线SSID uci set wireless.@wifi-iface[0].network=lan //无线链接到lan上 uci set wireless.@wifi-iface[0].encryption=psk2 //设置加密为WPA2-PSK uci set wireless.@wifi-iface[0].key=[密码] //设置无线密码 提交应用配置 Shell代码 uci commit //应用 /etc/init.d/network restart //重启网络服务 安装luci管理界面 Shell代码 opkg update // 更新软件列表 opkg list-installed // 查看已安装软件 opkg install luci // 安装LUCI opkg install luci-i18n-chinese // 支持中文 luci-app-firewall - 0.10.0-1 luci-i18n-english - 0.10.0-1 luci-lib-core - 0.10.0-1 luci-lib-ipkg - 0.10.0-1 luci-lib-lmo - 0.10.0-1 luci-lib-nixio - 0.10.0-1 luci-lib-sys - 0.10.0-1 luci-lib-web - 0.10.0-1 luci-mod-admin-core - 0.10.0-1 luci-mod-admin-full - 0.10.0-1 luci-proto-core - 0.10.0-1 luci-proto-ppp - 0.10.0-1 luci-sgi-cgi - 0.10.0-1 luci-theme-base - 0.10.0-1 luci-theme-openwrt - 0.10.0-1 即可完成LUCI的安装。 输入以下命令开启支持web服务的uhttpd,并设置其为自启动: Shell代码 /etc/init.d/uhttpd enable # 开机自启动 /etc/init.d/uhttpd start # 启动uhttpd - Wifidog 你可以尝试执行以下命令安装Wifidog: opkg update # Optional opkg install wifidog --sftp安装 opkg update opkg install vsftpd openssh-sftp-server /etc/init.d/vsftpd enable /etc/init.d/vsftpd start 小米端口转发命令: 通过修改 /etc/config/firewall 这个文件来实现开放自己需要的端口到外网。 config rule 'httpdwan' option src 'wan' option dest_port '8088' option proto 'tcp' option target 'ACCEPT' option name ''\''httpd wan accept tcp port 8088'\''' 保存后,执行 /etc/init.d/firewall restart 重启防火墙。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值