脚本可快速为用户生成ssh免密的keygen,建议扔到服务器的/etc/profile.d/目录
Cshell模式
#!/bin/csh if ( ! -e ~/.ssh/id_rsa ) then mkdir -p ~/.ssh chmod 700 ~/.ssh ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" >/dev/null cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys echo "Host * ">~/.ssh/config echo "StrictHostKeyChecking no">>~/.ssh/config chmod 644 ~/.ssh/config endif
Bash模式
#!/bin/bash if [ ! -f ~/.ssh/id_rsa ];then mkdir -p ~/.ssh >/dev/null 2>&1 chmod 700 ~/.ssh ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" >/dev/null cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys echo "Host * ">~/.ssh/config echo "StrictHostKeyChecking no">>~/.ssh/config chmod 644 ~/.ssh/config fi
网友留言:
正确的做法是创建用户的时候调用脚本产生ssh key就可以了
你扔/etc/profile每次新起一个shell都得判断一遍,累不累啊
用户的home目录是挂载共享的,也就是说,你每台服务器上的home都应该一样。