来自《灵犀志趣》的脚本来完成无密码验证,省事省力。

   执行方式 sh nopasswd USER REMOTE_HOST

   执行此脚本前,请确认:

  • 本机上已有 id_dsa.pub ,若无。 使用命令 ssh-keygen -t dsa 获得。

  • 远程机上登录用户家目录下,已经有 .ssh 文件夹,若无创建之。


nopasswd: 将本地已经生成的id_dsa.pub拷贝到需要访问的机器home下,然后将id_dsa.pub的内容增加到~/.ssh/authorized_keys中,最后确保权限设置正确。

#!/bin/sh

scp ~/.ssh/id_dsa.pub  $1@$2:~/
ssh $1@$2 " touch ~/.ssh/authorized_keys ; cat ~/id_dsa.pub  >> ~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys; exit"

相关文章:

  • 2021-06-06
  • 2022-12-23
  • 2021-09-03
  • 2021-10-09
  • 2021-10-09
  • 2021-10-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-09
  • 2021-06-27
  • 2022-12-23
  • 2021-10-09
  • 2021-08-14
  • 2022-01-19
相关资源
相似解决方案