安装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 ...
随机推荐
- CentOS 6.9 安装 ftp 服务器
昨天为了方便上传写好的博客 .md 文件到服务器上,就在服务器搭建了一个 ftp 服务端用来上传写好的博客.很久之前我也使用虚拟机搭建过 ftp 服务器,但是时间久了,很多都忘记了.于是乎又一顿 Go ...
- Python序列——列表
列表是什么 1 创建列表 2 访问列表和更新列表 列表相关操作 内建函数对列表的支持 1 cmp 2 序列类型函数 列表内建函数 列表应用 1 堆栈 2 队列 1. 列表是什么 列表也是序列的一种.列 ...
- jquery特效(2)—选项卡
最近公司有个页面正好用到了选项卡,我就写了一下,感觉还不错,都挺简单的. 下面来看动态效果: 一.主体程序 <!DOCTYPE html> <html> <head> ...
- Appium java 环境配置
一.安装node.js 下载地址:http://pan.baidu.com/s/1qYyNDm8 点击安装,next下一步就ok. 安装完成,命令行输入:npm 这样显示的话就ok了. 二.下载Ap ...
- CSS元素水平垂直居中方法总结(主要对大漠以及张鑫旭博客所述方法进行了归纳)
本文主要是对主流居中方法进行了归纳,有些地方甚至就是把别人的代码直接复制过来的,没有什么自己的东西,除了大漠以及张鑫旭的方法外,还有来自司徒正美.怿飞博客的几个方法 以下方法,由于测试环境的原因,IE ...
- 解决 Git 冲突的 14 个建议和工具
Git 非常善于合并代码.代码的合并在本地完成,快速而且灵活.正常情况下每次从不同分支合并内容时,冲突有可能会发生.通常解决冲突很简单,就如同知道(如何)选择(保留)重要的更改一样,而有时解决冲突则需 ...
- js Date 函数方法及日期计算
js Date 函数方法 var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份 ...
- Linux 修改所属组与所属人
1.chown work /test/* 修改test文件夹下所有文件的所属人(owner)为work 2.chgrp work /test/* 修改test文件夹下所有文件的所属组(group)为w ...
- 自然语言处理:问答 + CNN 笔记
参考 Applying Deep Learning To Answer Selection: A Study And An Open Task follow: http://www.52nlp.cn/ ...
- python print 字体颜色
例子: print '\033[35;43m(1)ip转换成数字\033[0m' \033[35;43m ===>35列属于字颜色,43列属于背景颜色 字背景颜色范围: 40--49 4 ...