UNPKG

1.62 kBMarkdownView Raw
1sshpass
2===
3
4免交互 SSH 登录工具。
5
6## 补充说明
7
8免交互 SSH 登录工具,但不要用在生产服务器上。
9
10如果你想自动在 SSH 登录提示符中提供**密码****用户名**怎么办?这时 **sshpass** 就可以帮到你了。
11
12**sshpass** 是一个简单、轻量级的命令行工具,通过它我们能够向命令提示符本身提供密码(非交互式密码验证)。
13
14### 安装
15
16```shell
17# RedHat/CentOS
18yum install sshpass
19
20# Debian/Ubuntu
21apt-get install sshpass
22```
23
24### 语法
25
26```shell
27sshpass (选项)
28```
29
30### 选项
31
32```shell
33用法: sshpass [-f|-d|-p|-e] [-hV] 命令 参数
34 -f 文件名 从文件中获取密码
35 -d 数字 使用数字作为文件描述符来获取密码
36 -p 密码 将密码作为参数提供(安全上不明智)
37 -e 密码以环境变量 "SSHPASS" 的形式传递
38 如果没有参数 - 密码将从标准输入中获取
39
40 -P 提示 sshpass 搜索以检测密码提示的字符串
41 -v 显示详细信息
42 -h 显示帮助信息(本屏幕)
43 -V 打印版本信息
44只能使用 -f、-d、-p 或 -e 中的一个
45```
46
47### 实例
48
491.明文传输密码(**不建议**
50
51```shell
52sshpass -p 'my_pass_here' ssh aaronkilik@10.42.0.1 'df -h'
53```
54
552.使用文件传输密码
56
57```shell
58sshpass -f password_filename ssh aaronkilik@10.42.0.1 'df -h'
59```
60
613.使用环境变量 `SSHPASS`
62
63```shell
64sshpass -e ssh aaronkilik@10.42.0.1 'df -h'
65```
66
67更多使用详情请参考 [https://linux.cn/article-8086-1.html](https://linux.cn/article-8086-1.html) 。
\No newline at end of file