运维免密码登陆ssh输入一次密码管8小时

vi .ssh/config 添加

Host *
ServerAliveInterval 180
ControlPersist yes
ControlMaster auto
ControlPersist 8h
ControlPath ~/.ssh/.sessions/%C
Host */*
ControlMaster auto
ControlPersist yes
ControlPersist 8h
ControlPath ~/.ssh/.sessions/%%C
ProxyCommand ssh -l %r -p %p -W %h:%p

Host mon     
  Hostname ip     
  User root     
  Port 22

 

 利用sshpass自动输入密码 vi .zshrc

alias sshp='sshpass -p password ssh -p 22 -l root'
或者把密码写环境变量里export SSHPASS=password
alias sshp='sshpass -e ssh -p 22 -l root'

 

上一篇:ansible入门快速上手使用教程


下一篇:Git基础教程