安装Net::OpenSSH 库
perl 离线安装 Net::OpenSSH 库
Net::OpenSSH 库 下载地址
https://metacpan.org/pod/Net::OpenSSH
直接获取安装包命令
wget https://cpan.metacpan.org/authors/id/S/SA/SALVA/Net-OpenSSH-0.74.tar.gz
编译方式
perl Makefile.PL
make && make install
Net::OpenSSH 库 还需要用到IO:Pty 库,所以我们还需要继续安装 IO:Pty 库
IO:Pty 库 下载地址
https://metacpan.org/pod/IO::Pty
直接获取安装包命令
wget https://cpan.metacpan.org/authors/id/T/TO/TODDR/IO-Tty-1.12.tar.gz
编译方式
perl Makefile.PL
make && make install
测试test.pl 程序
use Net::OpenSSH;
use strict;
use Encode;
use POSIX qw(strftime); my $host="192.168.57.129";
my $user_name="root";
my $password="chen"; my $ssh = Net::OpenSSH->new($host,user => $user_name,password => $password);
my @ls = $ssh->capture("ls /");
$ssh->error and die "remote ls command failed: " . $ssh->error;
print "test:\n".@ls."\n";
foreach my $item (@ls) {
print "-------".$item."\n";
}
print "========================\n";
运行方法
perl test.pl
这里给大家提一个醒,由于Net::OpenSSH 的库在连接远程服务器时,客户端机器的IP 地址必须要要在 被访问服务器的 ~/.ssh/known_hosts 文件下,否则会报告错误。
错误的信息如下:
remote ls command failed: unable to establish master SSH connection: the authenticity of the target host can't be established; the remote host public key is probably not present on the '~/.ssh/known_hosts' file at test.pl line 13.
详细的解释可以参考官方说明,https://metacpan.org/pod/Net::OpenSSH
Check you can connect to the remote host using the same parameters you are passing to Net::OpenSSH. In particular, ensure that you are running ssh as the same local user. If you are running your script from a web server, the user would probably be www, apache or something alike. Common problems are: Remote host public key not present in known_hosts file. The SSH protocol uses public keys to identify the remote hosts so that they can not be supplanted by some malicious third parties. For OpenSSH, usually the server public key is stored in /etc/ssh/ssh_host_dsa_key.pub or in /etc/ssh/ssh_host_rsa_key.pub and that key should be copied into the ~/.ssh/known_hosts file in the local machine (other SSH implementations may use other file locations). Maintaining the server keys when several hosts and clients are involved may be somewhat inconvenient, so most SSH clients, by default, when a new connection is established to a host whose key is not in the known_hosts file, show the key and ask the user if he wants the key copied there. Wrong remote host public key in known_hosts file. This is another common problem that happens when some server is replaced or reinstalled from scratch and its public key changes becoming different to that installed on the known_hosts file. The easiest way to solve that problem is to remove the old key from the known_hosts file by hand using any editor and then to connect to the server replying yes when asked to save the new key. Wrong permissions for the ~/.ssh directory or its contents. OpenSSH client performs several checks on the access permissions of the ~/.ssh directory and its contents and refuses to use them when misconfigured. See the FILES section from the ssh() man page. Incorrect settings for password or public key authentication. Check that you are using the right password or that the user public key is correctly installed on the server.
安装Net::OpenSSH 库的更多相关文章
- 安装Python算法库
安装Python算法库 主要包括用NumPy和SciPy来处理数据,用Matplotlib来实现数据可视化.为了适应处理大规模数据的需求,python在此基础上开发了Scikit-Learn机器学习算 ...
- kali4.0 安装32位库
一.前情提要: OS:Kali4.0 64bit 二.安装32位库: 错误方法:sudo apt-get install lib6-i386 正确方法如下: 1.先以root用户身份登陆: su ro ...
- ubuntu 下安装32位库 ia32-libs方法
这两天在整Linux系统,要配置JDK,SDK环境,但是SDK配置使用的时候,提示没有权限. 需要安装32位库来解决,还有就是在修改文件的时候提示不能修改.唉...反正就是没有办法正常操作啦 后来根据 ...
- phpstudy 出现“请自行检查是否安装VC9运行库??”问题 -- 缺少vc9库
phpStudy是一款PHP调试环境的程序集成包,该程序包集成最新的Apache+PHP+MySQL+phpMyAdmin+ZendOptimizer,一次性安装,无须配置即可使用,是非常方便.好用的 ...
- [django]在virtualenv下安装的第三方库的使用方法
在virtualenv下安装的第三方库,例如south, requests等,如果想在django中使用,需要先将库添加到settings.py的INSTALLED_APPS中, 以south, re ...
- 安装php扩展库
无法加载'pdo_mysql' ,因为需要pdo这个module.PHP Warning: Cannot load module 'pdo_mysql' because required module ...
- 解决安装vc2005运行库时提示Command line option syntax error.Type Command/?for Help
安装vc2005运行库时提示 这是因为它要自解压到用户的临时文件夹下,如果用户名中带中文,就会报错. 简单的解决方法是,手动解压之,再安装 当然,你也可以修改用户名或者再新建个用户.
- [转载~笔记]CentOS单独编译安装PHP gd库扩展
http://www.nowamagic.net/librarys/veda/detail/2610 安装gd前置库: freetype, jpegsrc, libpng 1. freetypewge ...
- ubuntu下安装 openssl 开发库
ubuntu下安装 openssl 开发库 检查是否已安装openssl: sudo apt-get install openssl 如果已安装执行以下操作:sudo apt-get install ...
随机推荐
- ElasticSearch(十三) bulk api奇特的json格式的原因
bulk api的语法 正常的语法: {"action": {"meta"}}\n {"data"}\n {"action&quo ...
- DuiLib笔记之自定义标题栏以及响应按钮点击事件
在博文DuiLib笔记,基于WindowImplBase的基础模板的基础上,修改皮肤文件如下 <?xml version="1.0" encoding="utf-8 ...
- tornado之表单和模板
之前在indexHandler中通过self.write()方法在对应的网页中写入具体的字符信息. 如果我们想直接返回一个网页那么这个时候就需要用到模板了 首先在工程目录下新建一个template文件 ...
- html5 canvas基本用法
通过对canvas的初步了解,经过几天的总结,吧canvas的基本用法总结如下:方便以后查阅 <!doctype html> <html> <head> <m ...
- Disruptor学习杂记
慎入,有点乱,只是学习记录,disruptor_2.10.4 1.Disruptor对象有一个EventProcessorRepository对象 2.EventProcessorReposito ...
- (linux)BSP板级支持包开发理解
1. 概述 嵌入式系统由硬件环境.嵌入式操作系统和应用程序组成,硬件环境是操作系统和应用程序运行的硬件平台,它随应用的不同而有不同的要求.硬件平台的多样性是嵌入式系统的主要特点,如何使嵌入式操作系统在 ...
- 持续集成工具hudson【转载】
第一节 我的理解 项目中使用了hudson,那么hudson是处在怎样的一个地位呢? 首先就我自己的认知,项目中hudson的作用有一下几点: 1.获取svn服务器上的最新代码: 2.把最新代码编译打 ...
- javascript学习第一天
从大学第一次接触到JavaScript,到现在一直是个软肋,之前也是学习过一遍,但是缺乏系统学习,基础不牢,那么今天开始从基础部分学起来,今天是第一天,每天至少要保证效率,也要保证学习质量. 恩,要按 ...
- SCUT125 华为杯 D.笔芯回文 —— DP
题目链接: https://scut.online/p/125 题目描述 bxbx有一个长度一个字符串SS,bxbx可以对其进行若干次操作. 每次操作可以删掉一个长度为k(1 \leq k \leq ...
- U盘安装Ubuntu 14.04 LTS正式版
Ubuntu 14.04 LTS正式版发布,而且提供五年的支持和维护服务.Ubuntu 14.04是Ubuntu开发团队历经五年的心血之作.许多新手都喜欢把Linux安装文件刻录成光盘再安装,而安装好 ...