芯片设计交流论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 42|回复: 0

[转贴] 快速生成ssh-keygen免密登录脚本

[复制链接]

21

主题

0

回帖

70

积分

注册会员

积分
70
发表于 3 天前 | 显示全部楼层 |阅读模式
脚本可快速为用户生成ssh免密的keygen,建议扔到服务器的/etc/profile.d/目录
Cshell模式
  1. #!/bin/csh
  2. if ( ! -e ~/.ssh/id_rsa ) then
  3.        mkdir -p ~/.ssh
  4.        chmod 700 ~/.ssh
  5.        ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" >/dev/null
  6.        cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
  7.        echo "Host * ">~/.ssh/config
  8.        echo "StrictHostKeyChecking no">>~/.ssh/config
  9.        chmod 644 ~/.ssh/config
  10. endif
复制代码

Bash模式
  1. #!/bin/bash
  2. if [ ! -f ~/.ssh/id_rsa ];then
  3.        mkdir -p ~/.ssh >/dev/null 2>&1
  4.        chmod 700 ~/.ssh
  5.        ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" >/dev/null
  6.        cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
  7.        echo "Host * ">~/.ssh/config
  8.        echo "StrictHostKeyChecking no">>~/.ssh/config
  9.        chmod 644 ~/.ssh/config
  10. fi
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|芯片设计交流论坛

GMT+8, 2025-11-24 20:14 , Processed in 0.045949 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表