【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终端。
刷固件:— 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>
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.
工作图片如下: