Linux下如何使用sshpass绕过SSH密码验证

发布时间:2022-01-26 11:04:47 作者:小新
来源:亿速云 阅读:357

这篇文章将为大家详细讲解有关Linux下如何使用sshpass绕过SSH密码验证,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

ssh 直接使用 TTY 访问,以确保密码是用户键盘输入的。 sshpass 在专门的 tty 中运行 ssh,以误导 ssh 相信它是从用户接收到的密码。

Linux下如何使用sshpass绕过SSH密码验证

1. 安装

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

检查是否安装

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

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

View Code

[root@yaowenxu Desktop]# sshpassUsage: 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 123 ssh root@10.66.65.15

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

ssh -o StrictHostKeyChecking=no

来解决

➜  Desktop sshpass  -p 123 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  2 10:51:29 2018

5. 优缺点

优点: 快速,便捷

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


关于“Linux下如何使用sshpass绕过SSH密码验证”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

推荐阅读:
  1. 交换机配置ssh密码验证登录方式
  2. ssh免密码登录 用密钥验证

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux sshpass ssh

上一篇:Linux下如何使用ntpdate同步时间

下一篇:@Transactional注解怎么用

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》