经常我们使用脚本登入服务器的时候,如果使用ssh 命令,经常会提示密码输入,我们不得不手动输入密码,因为ssh 没有 密码的选项。

为了能绕过交互式验证,我们使用sshpass命令解决这个问题:

1. 安装

➜  Desktop sudo yum install sshpass
[sudo] password for xuyaowen:
Last metadata expiration check: :: ago on Mon Jul :: AM CST.
Package sshpass-1.06-.fc28.x86_64 is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!

检查是否安装

[root@yaowenxu Desktop]# rpm -qa sshpass
sshpass-1.06-.fc28.x86_64

2. 查看 sshpass 命令帮助, 也可以使用 man sshpass

NAME
sshpass - noninteractive ssh password provider SYNOPSIS
sshpass [-ffilename|-dnum|-ppassword|-e] [options] command arguments DESCRIPTION
This manual page documents the sshpass command. sshpass is a utility designed for running ssh using the mode referred to as "keyboard-interactive" password authentication, but in non-interactive mode. ssh uses direct TTY access to make sure that the password is indeed issued by an interactive keyboard user. Sshpass runs ssh in a dedicated tty, fooling
it into thinking it is getting the password from an interactive user. The command to run is specified after sshpass' own options. Typically it will be "ssh" with arguments, but it can just as well be any other command. The
password prompt used by ssh is, however, currently hardcoded into sshpass.
[root@yaowenxu Desktop]# 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 -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

3. 使用密码验证登录

➜  ~ sshpass -p  ssh root@10.66.65.15

4. ssh 第一次登录提示问题使用:

ssh -o StrictHostKeyChecking=no

来解决

➜  Desktop sshpass  -p  ssh -o StrictHostKeyChecking=no root@10.66.8.142
Warning: Permanently added '10.66.8.142' (ECDSA) to the list of known hosts.
Last login: Mon Jul ::

5. 优缺点

优点: 快速,便捷

缺点: 密码明文暴露,可以使用 history 命令查找到

sshpass 绕过ssh 密码交互式验证的更多相关文章

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

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

  2. 终端-Linux命令之非交互SSH密码验证-Sshpass

    Sshpass是使用SSH所谓的"交互式键盘密码身份验证"以非交互方式执行密码身份验证的工具 通俗来说就是 使用ssh密码登录 是需要在连接时手动输入密码的,没办法明文连接,如下图 ...

  3. sshpass非交互SSH密码验证

    1.yum安装yum install sshpass -y1.1编译安装yum install wget -ywget http://sourceforge.net/projects/sshpass/ ...

  4. sshpass-Linux命令之非交互SSH密码验证

    sshpass-Linux命令之非交互SSH密码验证 参考网址:https://www.cnblogs.com/chenlaichao/p/7727554.html ssh登陆不能在命令行中指定密码. ...

  5. 【转】sshpass-Linux命令之非交互SSH密码验证

      sshpass-Linux命令之非交互SSH密码验证 ssh登陆不能在命令行中指定密码.sshpass的出现,解决了这一问题.sshpass用于非交互SSH的密码验证,一般用在sh脚本中,无须再次 ...

  6. [原创]内网SSH密码爆破工具sshcrack(配合Cscan批量弱口令检测)

    0x000 前言 sshcrack是一个命令行下的SSH密码爆破工具,适用于内渗中SSH密码检测 当然也可用于外网SSH密码爆破,支持Windows/Linux,其它系统未测.Tip1 0x001 目 ...

  7. [原创]内网渗透专用SSH连接工具sshcmd/sshshell/ssh密码破解以及Kali开启SSH

    目录 1.Kali开启SSH 2.SSH连接工具优缺点 3.渗透专用SSH连接工具 4.ssh执行cmd源码 5.批量SSH密码破解 6.相关工具下载 0x001 SSH配置 1.打开文件 etc/s ...

  8. ssh免密验证,shell批量设置

    ssh免密验证,shell批量设置 #ssh免密验证,shell自动设置 echo '#!/bin/sh . /etc/init.d/functions [[ -f /usr/bin/expect ] ...

  9. 简单绕过Chrome密码查看逻辑,查看浏览器已保存的密码

    简单绕过Chrome密码查看逻辑,查看浏览器已保存的密码   利用场景: 同事或朋友外出有事,电脑未锁屏离开座位.可以利用这一间隙,查看Ta在Chrome浏览器上保存的账号密码 查看逻辑: 当我们要查 ...

随机推荐

  1. PBN飞越转弯Flyover衔接TF、CF航段保护区组图

    PBN飞越转弯Flyover衔接TF.CF航段虽不常用,但也很重要,与旁切转弯有一定的相似性. 飞越转弯 flyover-TF/CF 叠加图: 飞越转弯 flyover-TF/CF 分解图:

  2. java权限控制以及变量的初始化

    知识是靠积累的,不断的温习会帮你让你遇到许多问题,解决完这些问题之后,会收获许多,233333333333333. 1.java访问控制符 2.java变量初始化问题 默认构造方法的名字与类名相同,它 ...

  3. JS中for循环变量作用域--解决for循环异步执行的问题

    被这个问题困惑了很久,终于在网上找到了答案,感谢~ 现在分享给大家~ js中如何让一个for循环走完之后,再去执行下面的语句? 这涉及for循环变量作用域的问题,js中作用域只有函数作用域和全局作用域 ...

  4. [转]centos7 移动mysql5.7.19 数据存储位置

    本文转自:https://blog.csdn.net/chpllp/article/details/78211351 场景:随着数据量的增加,mysql所在的磁盘已占满,需要将data移动到空间较大的 ...

  5. jQuery.Ajax()执行WCF Service的方法

    Insus.NET有在上一篇<ASP.NET MVC呼叫WCF Service的方法>http://www.cnblogs.com/insus/p/3720547.html 直接呼叫WCF ...

  6. IntelliJ IDEA 2016.2 注册破解激活教程

    下载了IntelliJ IDEA 尽然需要激活,整了终于找到解决的办法了,记录下来. IntelliJ IDEA 2016.2下载地址:http://www.jetbrains.com/idea/do ...

  7. Java面向对象-------多态总结

    1.多态:是同一个行为具有多个不同表现形式或形态的能力. 多态就是同一个接口,使用不同的实例而执行不同操作,如图所示: 多态性是对象多种表现形式的体现. 2.多态作用: 1. 消除类型之间的耦合关系 ...

  8. java设计模式-----22、状态模式

    概念: State模式也叫状态模式,是行为设计模式的一种.State模式允许通过改变对象的内部状态而改变对象的行为,这个对象表现得就好像修改了它的类一样. 根据这个概念,我们举个例子 public c ...

  9. 常见Java问题二

    1.什么是B/S架构?什么是C/S架构? B/S browser/server Web应用程序 C/S Client/Server 桌面应用程序 2.String str="www" ...

  10. js-jQuery性能优化(二)

    5.数组方式使用jQuery对象 使用jQuery选择器获取结果是一个jQuery对象.然而,jQuery类库会让你感觉正在使用一个定义了索引和长度的数组.在性能方面,建议使用简单的for或者whil ...