Linux - sshpass的安装与使用
ssh 登陆不能在命令行中指定密码,sshpass 的出现则解决了这一问题。它允许你用 -p 参数指定明文密码,然后直接登录远程服务器,它支持密码从命令行、文件、环境变量中读取。
安装
1、下载sshpass的安装包,并进行解压、编译……
[root@node1 home]# wget http://sourceforge.net/projects/sshpass/files/sshpass/1.05/sshpass-1.05.tar.gz
[root@node1 home]# tar xvzf sshpass-1.05.tar.gz
[root@node1 home]# cd sshpass-1.05
[root@node1 sshpass-1.05]# ll
总用量 396
-rw-r--r-- 1 1000 1000 35029 8月 6 2011 aclocal.m4
-rw-r--r-- 1 1000 1000 700 7月 22 2010 AUTHORS
-rw-r--r-- 1 1000 1000 1455 8月 6 2011 ChangeLog
-rw-r--r-- 1 1000 1000 4107 8月 6 2011 config.h.in
-rwxr-xr-x 1 1000 1000 201436 8月 6 2011 configure
-rw-r--r-- 1 1000 1000 865 8月 6 2011 configure.ac
-rw-r--r-- 1 1000 1000 17992 7月 22 2010 COPYING
-rwxr-xr-x 1 1000 1000 18615 8月 5 2011 depcomp
-rw-r--r-- 1 1000 1000 15578 8月 5 2011 INSTALL
-rwxr-xr-x 1 1000 1000 13663 8月 5 2011 install-sh
-rw-r--r-- 1 1000 1000 13179 8月 6 2011 main.c
-rw-r--r-- 1 1000 1000 145 7月 22 2010 Makefile.am
-rw-r--r-- 1 1000 1000 22973 8月 6 2011 Makefile.in
-rwxr-xr-x 1 1000 1000 11419 8月 5 2011 missing
-rw-r--r-- 1 1000 1000 213 7月 22 2010 NEWS
-rw-r--r-- 1 1000 1000 0 7月 22 2010 README
-rw-r--r-- 1 1000 1000 4742 8月 6 2011 sshpass.1
[root@node1 sshpass-1.05]# ./configure
[root@node1 sshpass-1.05]# make
[root@node1 sshpass-1.05]# make install
2、然后执行sshpass,可以查看到相关的帮助信息
[root@node1 sshpass-1.05]# sshpass
Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
-f filename Take password to use from file
-d number Use number as file descriptor for getting password
-p password Provide password as argument (security unwise)
-e Password is passed as env-var "SSHPASS"
With no parameters - password will be taken from stdin
-h Show help (this screen)
-V Print version information
At most one of -f, -d, -p or -e should be used
[root@node1 sshpass-1.05]#
使用
# 使用sshpass访问node2节点并执行hostname命令
[root@node1 sshpass-1.05]# sshpass -p 'harley' ssh root@192.168.56.112 "hostname"
node2
[root@node1 sshpass-1.05]#
可以通过sshpass进行一套未配置免密的集群的基础环境检查等批量操作。
Q&A
Q1:执行 ./configure编译时报错
[root@node1 sshpass-1.05]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/0-transwarp-home/sshpass-1.05':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
然后根据 checking for gcc... no
检查了gcc的安装情况,然后安装了gcc
[root@node1 sshpass-1.05]# yum list installed | grep gcc
libgcc.x86_64 4.4.7-4.el6 @anaconda-CentOS-201311272149.x86_64/6.5
[root@node1 sshpass-1.05]#
[root@node1 sshpass-1.05]# yum provides gcc
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
gcc-4.4.7-4.el6.x86_64 : Various compilers (C, C++, Objective-C, Java, ...)
Repo : os65
Matched from:
[root@node1 sshpass-1.05]# yum install gcc
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-4.el6 will be installed
--> Processing Dependency: cpp = 4.4.7-4.el6 for package: gcc-4.4.7-4.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-4.el6.x86_64
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7- 1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1. 2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-4.el6 will be installed
--> Processing Dependency: libmpfr.so.1()(64bit) for package: cpp-4.4.7-4.el6.x8 6_64
--> Running transaction check
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
gcc x86_64 4.4.7-4.el6 os65 10 M
Installing for dependencies:
cloog-ppl x86_64 0.15.7-1.2.el6 os65 93 k
cpp x86_64 4.4.7-4.el6 os65 3.7 M
mpfr x86_64 2.4.1-6.el6 os65 157 k
ppl x86_64 0.10.2-11.el6 os65 1.3 M
Transaction Summary
================================================================================
Install 5 Package(s)
Total download size: 15 M
Installed size: 33 M
Is this ok [y/N]: y
Downloading Packages:
--------------------------------------------------------------------------------
Total 75 MB/s | 15 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mpfr-2.4.1-6.el6.x86_64 1/5
Installing : cpp-4.4.7-4.el6.x86_64 2/5
Installing : ppl-0.10.2-11.el6.x86_64 3/5
Installing : cloog-ppl-0.15.7-1.2.el6.x86_64 4/5
Installing : gcc-4.4.7-4.el6.x86_64 5/5
Verifying : gcc-4.4.7-4.el6.x86_64 1/5
Verifying : ppl-0.10.2-11.el6.x86_64 2/5
Verifying : cloog-ppl-0.15.7-1.2.el6.x86_64 3/5
Verifying : mpfr-2.4.1-6.el6.x86_64 4/5
Verifying : cpp-4.4.7-4.el6.x86_64 5/5
Installed:
gcc.x86_64 0:4.4.7-4.el6
Dependency Installed:
cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-4.el6
mpfr.x86_64 0:2.4.1-6.el6 ppl.x86_64 0:0.10.2-11.el6
Complete!
[root@node1 sshpass-1.05]#
再次执行 ./configure 编译时,发现内容比较多,看上去很正常,就继续往下走了。
[root@node1 sshpass-1.05]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking for ANSI C header files... (cached) yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking for unistd.h... (cached) yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for an ANSI C-conforming const... yes
checking for pid_t... yes
checking for ssize_t... yes
checking vfork.h usability... no
checking vfork.h presence... no
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking whether gcc needs -traditional... no
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking types of arguments for select... int,fd_set *,struct timeval *
checking return type of signal handlers... void
checking for select... yes
checking for posix_openpt... yes
checking for strdup... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
[root@node1 sshpass-1.05]#
Linux - sshpass的安装与使用的更多相关文章
- NoSql1 在Linux(CentOS)上安装memcached及使用
前言: 今天是初五,生活基本要从过年的节奏中回归到正常的生活了,所以想想也该想想与工作有关的事情了.我之前在工作中会经常使用memcached和redis,但是自己一直没有时间系统的好好看 ...
- 在linux系统中安装VSCode(Visual Studio Code)
在linux系统中安装VSCode(Visual Studio Code) 1.从官网下载压缩包(话说下载下来解压就直接可以运行了咧,都不需要make) 访问Visual Studio Code官网 ...
- Linux 平台静默安装 Oracle客户端
需求:Linux平台,安装完整版Oracle客户端 Tips:如果只是用到sqlldr,sqlplus功能,可以参考<Linux上oracle精简版客户端快速部署>快速部署精简版:如果需要 ...
- 在Ubuntu和Linux Mint上安装Oracle JDK
在Ubuntu和Linux Mint上安装Oracle JDK 使用下面的命令安装,只需一些时间,它就会下载许多的文件,所及你要确保你的网络环境良好: sudo add-apt-repository ...
- Linux下yum安装MySQL
写这篇文章的原因是:在刚开始使用Linux操作系统时想要搭建LAMP环境,于是开始在Google和百度上各种寻找资料,碰到了不是很多的问题后,我决定写这篇文章总结一下在Linux下yum安装MySQL ...
- jemalloc在linux上从安装到使用
jemalloc在linux上从安装到使用 上次在引导大家安装Redis时提到可能会报错: 发现了redis有用到jemalloc. 首先,jemalloc是干什么的? 我们看看作者自己的介绍: j ...
- LINUX下编译安装PHP各种报错大集合
本文为大家整理汇总了一些linux下编译安装php各种报错大集合 ,感兴趣的同学参考下. nginx1.6.2-mysql5.5.32二进制,php安装报错解决: 123456 [root@clien ...
- VMware创建Linux虚拟机并安装CentOS(三)
选择“创建自定义布局”手动给Linux指定系统分区.交换分区,鼠标单击“下一步”按钮继续. 首先创建交Swap分区,鼠标单击“创建”按钮,在弹出的“生成存储”对话框中,生成分区选择“标准分区”:鼠标单 ...
- 【夯实PHP基础系列】linux下yum安装PHP APC
Alternative PHP Cache(可选PHP缓存),依赖于 PECL扩展库 用源码方式安装,直接yum就行了:首先要安装apc的依赖包:yum install php-pear php-de ...
- Linux(Centos)之安装Nginx及注意事项
1.Nginx的简单说明 a. Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器,期初开发的目的就是为了代理电子邮件服务器室友:Igor Sysoev开发 ...
随机推荐
- 痞子衡嵌入式:i.MXRT1170上PXP对CM7 TCM进行随机地址短小数据写入操作限制
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家分享的是i.MXRT1170上PXP对CM7 TCM进行随机地址短小数据写入操作限制. 在 MCU 里能够对片内外映射的存储器进行读写操作的主设 ...
- Qt+OPC开发笔记(一):OPCUA介绍、open62541介绍、编译与基础环境Demo
前言 本篇介绍OPC协议,相关开源库.编译并搭建Qt开发OPC的基础环境. Demo OPC OPC(OLE for Process Control)是一个工业标准,用于实现工业 ...
- 共建共荣金融生态!金融级数字底座“源启”与GoldenDB数据库完成互认证
近日,中电金信金融级数字底座"源启"顺利与金篆信科GoldenDB分布式数据库完成互认证.GoldenDB数据库安全稳定运行在"源启"之上,整体性能表现卓越,进 ...
- 第1章04节 | 常见开源OLAP技术架构对比
https://zhuanlan.zhihu.com/p/266402829 1. 什么是OLAP OLAP(On-line Analytical Processing,联机分析处理)是在基于数据仓库 ...
- Qt开源作品32-文本框回车焦点下移
一.前言 这个demo由于太过简单,而不用过多的文字描述,其实就是实现了在一个文本框中输入完成以后,回车自动跳入下一个文本框,焦点下移,这个在很多的社保系统.医疗系统等系统中很常用,因为那些系统需要很 ...
- 在 Ubuntu 上搭建 MinIO 服务器
在日常开发时,如果有文件上传下载的需求(比如用户头像),但是又不想使用对象存储,那么自己搭建一个 MinIO 服务器是一个比较简单的解决方案. MinIO 是一个基于 Apache License v ...
- BotSharp:又一个.Net重磅AI开源项目,.Net在AI领域开始崛起!
大家好,我是编程乐趣. 自从大模型爆火以来,.Net不管是官方.还是社区开源项目,都陆续推出很多重磅的项目. 在AI领域,对话即平台(CaaP)是未来的发展方向. 下面介绍一个开源项目,面向AI Bo ...
- linux下服务器稳定性压力测试工具stress安装使用介绍
linux下服务器稳定性压⼒测试⼯具stress安装使⽤介绍 一.简介 1.stress⼯具是Linux下一款压⼒测试⼯具, 可以模拟系统⾼负载运⾏ , 同时可协助我们进⾏软件稳 定性相关测试. ⼆. ...
- Netty与NIO服务器-NIO中的零拷贝
1.什么是零拷贝 一种避免 CPU 将数据从一块存储拷贝到另外一块存储的技术.针对操作系统中的设备驱动程序.文件系统以及网络协议堆栈而出现的各种零拷贝技术极大地提升了特定应用程序的性能,并且使得这些应 ...
- 2006. 差的绝对值为 K 的数对数目
给你一个整数数组 nums 和一个整数 k ,请你返回数对 (i, j) 的数目,满足 i < j 且 |nums[i] - nums[j]| == k . |x| 的值定义为: 如果 x &g ...