注意
:
所有操作都需要用
root
用户
.
步骤:
1.到support.rsa.com下载apache的最新的nicsftpagent.sh文件模板,然后根据实际情况修改。
Nicsftpagent.sh
文件需要修改的部分(红色部分)
=================================================
#!/bin/bash
#### Copyright Notice:
####
#### Copyright (c) 2007 Network Intelligence Corporation
####
#### Warning: This computer program is protected by copyright law and
#### international treaties. Unauthorized reproduction or distribution
#### of this program, or any portion of it, may result in severe civil
#### and criminal penalties, and will be prosecuted to the maximum
#### extent possible under the law.
####
#### RSA, The Security Division of EMC - Automated FTP/SCP/SFTP Script v2.7.11
####
###################
####
#### Begin User configuration
####
##########
########
######
####
#SILENT MODE
#produce no output to the console;
#set this to true when running from cron
#to reduce emails sent to root.
#SILENT=true
# Have the Solaris POSIX compliant binaries first in the path.
# The /usr/bin directory in Solaris doesn't have POSIX compliant
# binaries. This is particularly a problem for the awk command we are
# using. (ECE-138)
PATH=/usr/xpg6/bin:/usr/xpg4/bin:/usr/css/bin:$PATH
## Enter the hostname/IP address of the enVision machine to which you want to
## send the data files
ENVISION=128.168.100.201
## [
改成
envision IP]
## Enter the directories where the data files, which you need to send, exist. Separate
## multiple directories with a colon (:). This script must have read permissions
## to the directories.
## Example for multiple folders DATA_DIRECTORY=/var/log/:/var/log/audit
DATA_DIRECTORY=/opt/IBM/HTTPServer/logs/
## [apache
在
linux
上的日志存放目录
,
默认是把该目录下的
.log
文件全部上传
,
可以通过修改以下字段来达到读取其他文件的目的
:
FILESPEC=*.log]
## The directory on the enVision box where the files should be written to. This directory
## is relative to the enVision/ftp_files directory. If the directory name contains a
## space it will need to be double escaped. For example, if the directory name is
## "name with spaces", the variable needs to be set to "name\ with\ spaces".
ENVISION_DIRECTORY=APACHE_128.168.100.2
##
【
envision
上存放日志文件的目录
e:\nic\4100\
设备名
\ftp_files\
,该目录需要先在
envision
上创建
file reader
的
devices
以后会自动产生】
## The script keeps its persistent information in a directory. The
## script must have read and write permissions to this directory.
NIC_DIRECTORY=/usr/local/nic
##
【
linux
中
nicsftpagent.sh
文件存放的目录
,
默认不存在
,
需要通过
mkdir /usr/local/nic
创建】
## TRANSFER_METHOD=SFTP/SCP/FTP
## Select the method used to transfer the files to enVision. SFTP is recommended.
## valid options are FTP, SFTP and SCP
TRANSFER_METHOD=SFTP
##
【默认是
FTP,
需要改为
SFTP
】
## Enter a username (ftp default: anonymous; SFTP/SCP default: nic_sshd)
USERNAME=nic_sshd
##
【由于上一个字段把传输方式改成
SFTP,
所以需要把用户名改为
nic_sshd
】
## Enter a password (anonymous connections accept any password)
PASSWORD=default
## Enter the identity/private key file for the user specified above user
## default is $HOME/.ssh/id_rsa
IDENTITY=~/.ssh/id_rsa
## Enter the file matching specification. "*" will send any files in the directory. Separate
## multiplefielnames with a colon (:).
## Example for multiple files::
## FILESPEC=*.log:xyz.log
FILESPEC=*.log
#[
修改此字段可以让这脚本读取指定的文件
,
如
:
改成
FILESPEC=test.txt,
则脚本会把
DATA_DIRECTORY
字段定义的目录下的
test.txt
文件上传到指定目录
]
2.修改完成后上传到Linux,存放在/usr/local/nic目录下,须先创建/usr/local/nic目录。
注意:上传的时候一定要使用
ASCII
方式。
方法:
(1) 可以通过SecureCRT工具的ASCII文件传输功能,通过执行rz命令可以实现。参考:http://blog.csdn.net/tianlesoftware/article/details/7746005?1350988490
一般来说,安装
Linux
系统时会安装
rzsz
软件包,但有些定制安装的
linux
可能没有把
rzsz
包安装到系统,这对用
SecureCRT
这样的
windows
工具传输文件特别不方便,可以在安装
Liunx
后手动安装
rzsz
软件包。
1.1
获取
rzsz
软件包
在windows下访问http://freeware.sgi.com/source/rzsz/rzsz-3.48.tar.gz
下载rzsz-3.48.tar.gz软件包,使用ftp或
其 他
文件传输工具上传到Linux服务器进行安装
1.2
、解压软件包
# tar zxvf rzsz-3.48.tar.gz
将解压出一个名为src的目录。
1.3
、安装rzsz软件包(使用make posix)
注意:一定要进入到rzsz软件包解压出目录中,本案例是/home/src目录
# cd src
# ls
rzsz
的软件包安装与常规的GNU软 件不同,没有configure(配置)及make install (安装过程)文件。
执行命令make,查看相关提示信息
# make
根据自己的系统选择make的位置参数,一般情况下,选posix或linux就可以了,我选择posix参数执行如下:
# make posix
从输出部分可以看make所 进行的
工作
1.4
、将rz和sz脚本复制到目录/usr/bin下面,以便于使用。(或者写到用户$PATH环境变量中)
# cp rz sz /usr/bin
1.5
、设置环境变量
# export RZSZLINE=/dev/modem
如 果不设置这个环境变量,执行命令rz的时候,会有如下提示:
“Warning: Missing environment variable 'RZSZLINE' (Linux)
rz ready. Type "sz file ..." to your modem program
”。
注:这种方法设置的环境变量 只在当前的
shell
下 有效,如果想要永久生效,参见我的另一篇文章《Linux设置环境变量小结》
1.6
、验证安装
测 试
1
:rz命令(将windows中的文件上传到Liunx服务器)
使用SecureCRT连接到linux服务器,然后执行命令rz, 会弹出选择本机(windows)文件的对话框。
# rz
选择需要上传的文件后,点击“确 定”按钮就可把windows主机上的文件 通过ssh协议上传到Linux服务器。
上传文件所在位置:执行
rz
命令时所在的目录。
例如:本案例是
[root@localhost root]# rz //
在
/root
目录下执行的
rz
命令
则上传的
jdk
安装包会存储在
/root
目录下
技巧:
通过“Shifs”或“Ctrl”键可以实现多个文件的传输。
测试
2
:
sz
命令(将
Linux
下的文件下载到
windows
)
# sz <file1name> <file2name>
…
下载成功!
配置文件下载位置:
文件是下载成功了,但是有一个问题:文件下载到windows的什么位置?
很简单,文件下载位置的设置 是通过SecureCRT设置的,见下图所示:
点击【选项】-【会话选项】
(2) 如果直接通过FTP上传,会导致nicsftpagent.sh文件中的所有换行符全部变成^M,如:
## multiplefielnames with a colon (:).^M
## Example for multiple files:: ^M
## FILESPEC=*.log:xyz.log^M
,
原因是
windows
与
linux
的编码不一样
.
可以通过以下方式修正
:
在
/usr/local/nic
目录下输入
vi �Cb nicsftpagent.sh
à
shift :(
进入编辑模式
)
à
输入
%s/^M//g.--> shift :x(
保存配置
)
就可以把
nicsftpagent.sh
文件中的多余的
^M
字符替换掉
.
3.上传完成后给文件赋权,命令:chmod 755 nicsftpagent.sh(755:用户可读书执行,组可读写,其他可读写)
4.然后开始产生SFTP密钥对
4.1
使用
root
账号登陆
Linux
系统,执行命令:
ssh-keygen -b 1024 -t rsa
产生密钥对
.
注意
:
当提示输入
passphrase
时
,
不需要输入
,
直接
enter.
4.2
拷贝
/.ssh/id_rsa.pub
文件到
envision
的
e:\nic\4100\site-name\bin
目录下
4.3
打开
envision
的
CMD
命令行,进入
e:\nic\4100\site-name\bin
目录,执行命令:
add_winsshd_key.bat id_rsa.pub
5)使用root账号登陆linux,使用sftp命令建立连接:
6)验证
在
linux
下
cd /usr/local/nic
,然后执行命令
./nicsftpagent.sh
,运行
sftp
查看是否正常执行,成功后可以在
envision
收到日志了。
~