通过ssh -f检测linux ssh是否通的方法

首先下载sshpass,sshpass的用法大家自行百度

result="`sshpass -p "123456" ssh -f -p 2343 [email protected] 'pwd'`"
echo $result

如果有结果的话result会赋值成ssh登录后pwd的值(也就是/root)

ssh -f命令可以后台执行ssh远程命令

猜你喜欢

转载自blog.csdn.net/songduo22/article/details/112793073