经常我们使用脚本登入服务器的时候,如果使用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. mongodb副本集数据同步的踩坑

    一.故事 最近随着搞活动比较频繁导致数据库出现了波动,后端日志总是报数据库连接和读取的问题.由于我设置的是读写分离(伪的,通过设置副本集的读取策略实现的,设置的db.getMongo().setRea ...

  2. java arrayList vector 区别

    1. 关系图 List接口一共有三个实现类,分别是ArrayList.Vector和LinkedList 2. ArrayList.Vector和LinkedList区别 ArrayList是最常用的 ...

  3. java 写法推荐

    1. for循环 for (int i = 0; i < list.size(); i++) { int item = list.get(i); System.out.println(" ...

  4. PowerBuilder编程新思维3:适配(三层架构与GraphQL)

    PowerBuilder编程新思维3:适配(三层架构与GraphQL) PB在富客户端时代,是一线开发工具.随着网络发展,主流架构演进到三层架构的时代,PB拿不出有力的三层架构,已经明显力不从心,市场 ...

  5. 【PAT 甲级】1151 LCA in a Binary Tree (30 分)

    题目描述 The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has bo ...

  6. C# ABP 允许跨域请求

    备注:无论有没有安装 apb zero模块,都可以使用本文的跨域 首先配置Web Api: 1. 在Web API项目下,安装包 Install-Package Microsoft.AspNet.We ...

  7. C# Hadoop学习笔记(二)—架构原理

    一,架构   二.名词解释 (一)NameNode(简称NN),Hadoop的主节点,负责侦听节点是否活跃,对外开放接口等.在未来的大数据处理过程中,由于访问量和节点数量的不断增多,需要该节点的处理能 ...

  8. Docker 为 ASP.NET Core Web 应用程序生成 Docker 映像,创建并运行多个容器

    1.为 ASP.NET Core 应用程序生成 Docker 映像 下载这个事例项目:https://github.com/dotnet/dotnet-docker/tree/master/sampl ...

  9. JOffice中的权限管理--功能粒度的权限管理配置

    JOffice中的权限管理是基于角色的管理策略,采用Spring Security2的配置方式,同时能够结合EXT3来进行整个系统的权限管理,通过使用配置文件,进行整个系统的功能集中管理,包括系统左边 ...

  10. 转载--Json转换

    JSON的全称是”JavaScript Object Notation”,意思是JavaScript对象表示法,它是一种基于文本,独立于语言的轻量级数据交换格式.XML也是一种数据交换格式,为什么没 ...