sshpass: 用于非交互的ssh 密码验证

 ssh登陆不能在命令行中指定密码,也不能以shell中随处可见的,sshpass 的出现,解决了这一问题。它允许你用 -p 参数指定明文密码,然后直接登录远程服务器。 它支持密码从命令行,文件,环境变量中读取

安装sshpass

curl -O -L http://downloads.sourceforge.net/project/sshpass/sshpass/1.06/sshpass-1.06.tar.gz && tar xvzf sshpass-1.06.tar.gz && cd sshpass-1.06 && ./configure && make && sudo make install

安装后执行sshpass -V查看版本

sshpass -V
sshpass 1.06
(C) - Lingnu Open Source Consulting Ltd.
(C) - Shachar Shemesh
This program is free software, and can be distributed under the terms of the GPL
See the COPYING file for more information. Using "assword" as the default password prompt indicator.

sshpass -h查看帮助

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 -P prompt Which string should sshpass search for to detect a password prompt
-v Be verbose about what you're doing
-h Show help (this screen)
-V Print version information
At most one of -f, -d, -p or -e should be used

sshpass 参数 SSH命令(ssh,sftp,scp等)。
    参数:
        -p  password    //将参数password作为密码。
        -f   passwordfile //提取文件passwordfile的第一行作为密码。

    -d   使用数字作为文件描述符来获取密码
        -e  //将环境变量SSHPASS作为密码。

另外,对于ssh的第一次登陆,会提示:“Are you sure you want to continue connecting (yes/no)”,这时用sshpass会不好使,可以在ssh命令后面加上 -o StrictHostKeyChecking=no来解决。比如说上面的命令,就可以写作ssh -p efghi scp abc@192.168.0.5:/home/xxx/test /root -o StrictHostKeyChecking=no。

  

安装sshpass的更多相关文章

  1. mac使用brew安装sshpass

    brew安装sshpass brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Form ...

  2. ansible 提示安装sshpass

    之前用ansible一直用的root身份.机器之间又早早的做好了ssh信任.所以一直也没有出现什么问题.今天想想自己不能这么浪了,还是用回普通用户吧: 然而马上就遇到了第一个问题,ansible提示安 ...

  3. 安装sshpass:No package sshpass available

    安装sshpass的时候,报了如下错误: No Package sshpass available 更改软件源之后也无效.直到看到StackOverFlow上的一个问题:https://stackov ...

  4. MacOS Mojave 安装sshpass

    使用sshpass的场景 安装sshpass及各种常见小问题处理 测试 安全提示 使用sshpass的场景 在MacOS下使用ansible命令(inventory文件中使用了密码验证的方式)或者使用 ...

  5. CentOS7编译安装sshpass过程

    环境说明:centos 7 cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) 我的sshpass版本 sshpass-1.06. ...

  6. 苹果系统通过brew安装sshpass

    默认使用brew install sshpass会出现Warning: MD5 support is deprecated and will be removedin a future version ...

  7. 安装 sshpass

    https://www.cnblogs.com/lemon-le/p/6495007.html ssh远程执行命令并自动退出 https://blog.csdn.net/mjj291268154/ar ...

  8. brew安装sshpass

    有以下解决方法: # 1 brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formu ...

  9. centos6安装sshpass

    跳转机需要装这个 #!/bin/bash yum -y install gcc-c++ openssh-clients curl -o sshpass.tar.gz http://sourceforg ...

随机推荐

  1. 在linux上使用impdp命令时提示ORA-12154: TNS:could not resolve the connect identifier specified的问题

    今天在一台linux服务器上用impdp命令导入dmp文件时出现了错误: ORA: TNS:could not resolve the connect identifier specified 我使用 ...

  2. 处理flutter http请求添加application/json报错Cannot set the body fields of a Request with content-type “application/json”

    在flutter中在http请求发送时设置"content-type": "application/json"会出现报错Cannot set the body ...

  3. 用gcov来检查Qt C++程序的代码覆盖率

      最近才发现MinGW里面包含一个叫做gcov的工具,可以用来检查你的程序运行时调用了哪些代码,同时显示代码行被调用的次数.这个功能在代码的覆盖率和性能调优方便都能用上. 我的运行环境 Window ...

  4. layer.js错误Uncaught TypeError: i is not a function

    最初是要写一个管理后台来着,项目中需要用到弹出层,但是没有前端配合,我一个小PHP需要去写这玩意,怎么办呢?查了一些资料,发现layer对我来说还行,文档写的也比较完全,学习成本不高,就下决心用这个了 ...

  5. 基于MybatisUtil工具类,完成CURD操作

    package loaderman; import java.io.IOException; import java.io.Reader; import java.sql.Connection; im ...

  6. Swift3.0添加桥接文件

    注意是在target下不是project !!!纠结了好久表示...... 都这里一直编译错误,找不到该桥接文件,这里也是纠结了好久......最后原因是不能使用下划线就可以了....<表示这是 ...

  7. java数据结构之CopyOnWriteArrayList和CopyOnWriteArraySet

    一.什么是CopyOnWrite CopyOnWrite(写时复制)简称COW,这是一种利用读写分离的思想来实现线程安全的程序设计思路.顾名思义该思想就是在写的时候将原数据复制一份,然后在新的数据中进 ...

  8. 基于Opencv的梯度及其方向

    我们都知道梯度很好求,只需要将[-1,1] 与图像分别在x 方向和y方向卷积,即可求得两个方向上的梯度.不过在求梯度方向时,还是有些麻烦,因为梯度方向会指向360°的任何一个方向,所以直接用atan( ...

  9. 添加SSH keys到github帐号

    使用git clone命令从github上同步github上的代码库时,如果使用SSH链接(如我自己的esesgrid项目:git@github.com:hmilycc/esesgrid.git),而 ...

  10. 2019牛客暑期多校训练营(第六场)-D Move

    题目链接:https://ac.nowcoder.com/acm/contest/886/D 题意:给n个物品,每个物品有一个体积值,K个箱子,问箱子的最小体积为多少可将物品全部装下. 思路:比赛时一 ...