音乐分享(自动连播):
So cold
Not my baby
Wicked Game
What Is Love
Once Upon a Time
The Heart Of The Ocean
Sun Goes Down
Move That Body
Lose Control
云山
一趟
记录分享 记录是一种习惯 、分享是一种态度
sshpass 一个免交互式ssh登录工具
· 技术积累 · SSH

centos 下面使用yum方式安装sshpass

远程登录其他机器执行命令,之前一直用export 脚本的方式。现在感觉用这个更加方便一点,但是不安全,不建议在生产环境中使用此命令!

安装epel源

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum install sshpass -y

sshpass

命令使用:

sshpass  -p 'password' ssh user@ip 'cmd'
ssshpas -p '远程机器密码'  使用ssh  用户名@远程机器ip '要执行的命令'

第一次使用:
sshpass1

连接失败有错误:
执行后什么都没有提示,查看返回状态码为6 就是有问题喽~

解决:
先ssh user@ip 连接下,第一次手动匹配下 "yes",然后再执行sshpass 这个命令
sshpass2

再执行成功:
sshpass3


其他系统环境安装:

ubuntu下面使用apt-get 方式安装
# apt-get install sshpass

源码方式安装

#wget http://sourceforge.net/projects/sshpass/files/latest/download -O sshpass.tar.gz
#tar xf sshpass.tar.gz
#cd sshpass-1.06/
# ./configure
#make && make install

本文最后更新时间 2023-04-02
文章链接地址:https://me.jinchuang.org/archives/28.html
本文内容未来会持续更新·本站文章除注明[转载|引用|原文]出处外,均为本站原生内容,转载前请注明出处


留言

顶部