学习笔记:SSH快速登录

Marvin
2 min readNov 24, 2019

--

管理很多服务器的时候,SSH 登陆如果需要输入不同的IP和密码,是一个比较麻烦的事情,希望可以用一条命令就解决

用这个叫做 sshpass 的 linux 工具可以实现这个功能:

代码是:

sshpass -p ThePasswordHere ssh root@103.64.654.250

如果涉及到端口,则会有两个 -p 参数,使用无碍:

sshpass -p ‘2%7cnhgpD@y3’ ssh -p 37658 root@103.64.654.250

如果是第一次访问一台服务器,上面的命令会运行失败,因为:

办法就是修改 /etc/ssh/ssh_config 中的 StrictHostKeyChecking 的值

这是一篇 sshpass 的详细使用教程:

--

--

Marvin
Marvin

Written by Marvin

Notebook for self-learning

No responses yet