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. Java-Unsafe

    Unsafe 是 sun.misc 包下的一个类,可以直接操作堆外内存,可以随意查看及修改 JVM 中运行时的数据,使 Java 语言拥有了类似 C 语言指针一样操作内存空间的能力. Unsafe 的 ...

  2. 对String的内存解析

    @Test public void stringTest(){ /* * str1和str2地址指向字符串常量池 * 解析: str1 在字符串常量池中创建出java 地址例如为:0x456 * st ...

  3. usage memcache in linux

    set和add的区别 set可以重写存在的键值对, 也可以添加新的/ 而add不行, 如果存在已有的键名, 则add不会做更新该键值对, 不做任何事, 就是一次无效操作, 也就是, add可以防止重写 ...

  4. LC 802. Find Eventual Safe States

    In a directed graph, we start at some node and every turn, walk along a directed edge of the graph.  ...

  5. 最新create-react-native-app搭建rn教程

    一.前置条件: 1.nodeJS环境 2.npm 3.yarn 二.安装及项目初始化 1.安装脚手架 npm install -g create-react-native-app 2.用脚手架初始化创 ...

  6. Ajax案例-基于HTML,以GET或POST方式,检查注册用户名是否在数据库中已存在

    08_register.jsp <%@ page language="java" pageEncoding="UTF-8"%> <!DOCTY ...

  7. [Kerberos] Kerberos教程(一)

    1 简介 Kerberos协议旨在通过开放和不安全的网络提供可靠的身份验证,其中可能拦截属于它的主机之间的通信.但是,应该知道,如果使用的计算机容易受到攻击,Kerberos不提供任何保证:身份验证服 ...

  8. Kafka管理与监控——彻底删除topic

    一.配置 server.properties 设置 delete.topic.enable=true 如果没有设置 delete.topic.enable=true,则调用kafka 的delete命 ...

  9. Linux显存占用无进程清理方法(附批量清理命令)

    在跑TensorFlow.pytorch之类的需要CUDA的程序时,强行Kill掉进程后发现显存仍然占用,这时候可以使用如下命令查看到top或者ps中看不到的进程,之后再kill掉: fuser -v ...

  10. ASP.NET Core 入门笔记7,ASP.NET Core MVC 视图布局入门

    一.前言 1.本教程主要内容 ASP.NET Core MVC (Razor)视图母版页教程 ASP.NET Core MVC (Razor)带有Section的视图母版页教程 ASP.NET Cor ...