[root@dcnda2 ~]# cat /erikxue_chinese.sh
echo "------------------------------------------------------------------------------ "
echo " "
echo " 欢迎您使用 <被采集机SSH KEY> LINUX 辅助安装程序 V1.0"
echo " "
echo " 在使用之前请确认如下信息"
echo " "
echo "您本机存在 unionmon 用户;"
echo " "
echo "您已经拷贝 key 文件(authorized_keys)至系统“ /” (根目录)下"
echo " "
echo "------------------------------------------------------------------------------ "
echo " "
read -p "Press any key to continue." var
echo " "
echo "------------------------------------------------------------------------------ "
echo "| system is buiding your setting....... |"
echo "------------------------------------------------------------------------------ "
echo " "
/bin/cat >>/etc/ssh/sshd_config <<erikxue
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
erikxue
/bin/cat >> /etc/sudoers <<erikxue
unionmon ALL=(root) NOPASSWD:/usr/sbin/dmidecode,/usr/sbin/hwinfo, /usr/sbin/hbanyware/hbacmd,/usr/sbin/lsof,/sbin/ethtool,/sbin/mii-tool
erikxue
/bin/sed -i '/PATH=/ c PATH=$PATH:$HOME/bin:/sbin:/usr/bin' /home/unionmon/.bash_profile
/bin/bash /home/unionmon/.bash_profile
/bin/mkdir /home/unionmon/.ssh
/bin/mv /authorized_keys /home/unionmon/.ssh/authorized_keys
/bin/chown unionmon.unionmon /home/unionmon/ -R
/bin/chmod 700 /home/unionmon/ -R
/etc/init.d/sshd restart
echo " "
echo "_______________请确认.ssh目录的权限为700___________________________"
echo " "
/bin/ls -lsad /home/unionmon/.ssh
echo " "
echo "_______________请确认文件的权限为700_______________"
echo " "
/bin/ls -lsad /home/unionmon/.ssh/*
echo " "
echo "_______________请确认/etc/sudoers文件被正确修改__________________"
echo " "
/usr/bin/tail -n 2 /etc/sudoers
echo " "
echo "_______________请确认SSH文件被正确修改_______"
echo " "
/usr/bin/tail -n 3 /etc/ssh/sshd_config
echo " "
echo "_______________请确认unionmon用户PATH被正确修改_______"
echo " "
cat /home/unionmon/.bash_profile
echo "------------------------------------------------------------------------------ "
echo "正在删除原始authorized_keys,请稍后...."
echo "------------------------------------------------------------------------------ "
echo "------------------------------------------------------------------------------ "
echo "恭喜您安装成功!"
echo "------------------------------------------------------------------------------ "
[root@dcnda2 ~]#
¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥
以下是英文版
¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥
[root@dcnda2 ~]# cat /erikxue_english.sh
echo "------------------------------------------------------------------------------ "
echo " "
echo " You are welcome to use <LINUX SSH KEY> installer V1.0"
echo " "
echo " please confirm the following information before use"
echo " "
echo "1.this machine have the user unionmon ;"
echo " "
echo "2.You have to copy the key file (authorized_keys) to the system "/" (under the root directory)"
echo " "
echo "------------------------------------------------------------------------------ "
echo " "
read -p "Press any key to continue." var
echo " "
echo "------------------------------------------------------------------------------ "
echo "| system is buiding your setting....... |"
echo "------------------------------------------------------------------------------ "
echo " "
/bin/cat >>/etc/ssh/sshd_config <<erikxue
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
erikxue
/bin/cat >> /etc/sudoers <<erikxue
unionmon ALL=(root) NOPASSWD:/usr/sbin/dmidecode,/usr/sbin/hwinfo, /usr/sbin/hbanyware/hbacmd,/usr/sbin/lsof,/sbin/ethtool,/sbin/mii-tool
erikxue
/bin/sed -i '/PATH=/ c PATH=$PATH:$HOME/bin:/sbin:/usr/bin' /home/unionmon/.bash_profile
/bin/bash /home/unionmon/.bash_profile
/bin/mkdir /home/unionmon/.ssh
/bin/mv /authorized_keys /home/unionmon/.ssh/authorized_keys
/bin/chown unionmon.unionmon /home/unionmon/ -R
/bin/chmod 700 /home/unionmon/ -R
/etc/init.d/sshd restart
echo "------------------------------------------------------------------------------ "
echo " Please make sure the directory of .SSh permissions for 700 "
echo "------------------------------------------------------------------------------ "
/bin/ls -lsad /home/unionmon/.ssh
echo "------------------------------------------------------------------------------ "
echo " Please make sure the file permissions for 700 "
echo "------------------------------------------------------------------------------ "
/bin/ls -lsad /home/unionmon/.ssh/*
echo "------------------------------------------------------------------------------ "
echo " Make sure that the /etc/sudoers file is properly modified "
echo "------------------------------------------------------------------------------ "
/usr/bin/tail -n 2 /etc/sudoers
echo " "
echo "_______________Make sure that the SSH file is properly modified_______"
echo " "
/usr/bin/tail -n 3 /etc/ssh/sshd_config
echo "_______________Make sure that user unionmon'sPATH _______"
echo " "
cat /home/unionmon/.bash_profile
echo "------------------------------------------------------------------------------ "
echo "Deleting the original authorized_keys, please wait...."
echo "------------------------------------------------------------------------------ "
echo "------------------------------------------------------------------------------ "
echo "Congratulations on your successful installation!!!"
echo "------------------------------------------------------------------------------ "
[root@dcnda2 ~]#
####################################################################3
以下是效果图
#####################################################################
[root@dcnflow1 ~]# bash /erikxue_english.sh
------------------------------------------------------------------------------
You are welcome to use <LINUX SSH KEY> installer V1.0
please confirm the following information before use
1.this machine have the user unionmon 锛
2.You have to copy the key file (authorized_keys) to the system / (under the root directory)
------------------------------------------------------------------------------
Press any key to continue.
------------------------------------------------------------------------------
| system is buiding your setting....... |
------------------------------------------------------------------------------
/bin/mkdir: 无法创建目录‘/home/unionmon/.ssh’: 文件已存在
停止 sshd:[ 确定 ]
启动 sshd[ 确定 ]
------------------------------------------------------------------------------
Please make sure the directory of .SSh permissions for 700
------------------------------------------------------------------------------
4 drwx------ 2 unionmon unionmon 4096 1月 17 16:59 /home/unionmon/.ssh
------------------------------------------------------------------------------
Please make sure the file permissions for 700
------------------------------------------------------------------------------
4 -rwx------ 1 unionmon unionmon 395 1月 17 10:34 /home/unionmon/.ssh/authorized_keys
4 -rwx------ 1 unionmon unionmon 392 2012-12-18 /home/unionmon/.ssh/known_hosts
------------------------------------------------------------------------------
Make sure that the /etc/sudoers file is properly modified
------------------------------------------------------------------------------
aiuap dcnflow1=NOPASSWD:/usr/sbin/useradd,/usr/sbin/userdel,/usr/sbin/usermod,/usr/bin/passwd,/usr/sbin/groupadd,/usr/sbin/groupdel,/bin/cat
unionmon ALL=(root) NOPASSWD:/usr/sbin/dmidecode,/usr/sbin/hwinfo, /usr/sbin/hbanyware/hbacmd,/usr/sbin/lsof,/sbin/ethtool,/sbin/mii-tool
_______________Make sure that the SSH file is properly modified_______
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
_______________Make sure that user unionmon'sPATH _______
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/sbin:/usr/bin
export PATH
unset USERNAME
------------------------------------------------------------------------------
Deleting the original authorized_keys, please wait....
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Congratulations on your successful installation!!!
------------------------------------------------------------------------------
中文效果
[root@dcnda2 ~]# bash /erikxue_chinese.sh
------------------------------------------------------------------------------
欢迎您使用 <被采集机SSH KEY> LINUX 辅助安装程序 V1.0
在使用之前请确认如下信息
您本机存在 unionmon 用户;
您已经拷贝 key 文件(authorized_keys)至系统“ /” (根目录)下
------------------------------------------------------------------------------
Press any key to continue.
------------------------------------------------------------------------------
| system is buiding your setting....... |
------------------------------------------------------------------------------
/bin/mkdir: ome/unionmon/.ssh
sshd[ 0;39m ]
_______________请确认.ssh目录的权限为700___________________________
4 drwx------ 2 unionmon unionmon 4096 17 17:18 /home/unionmon/.ssh
_______________请确认文件的权限为700_______________
4 -rwx------ 1 unionmon unionmon 395 17 10:34 /home/unionmon/.ssh/authorized_keys
4 -rwx------ 1 unionmon unionmon 392 2012-12-18 /home/unionmon/.ssh/known_hosts
_______________请确认/etc/sudoers文件被正确修改__________________
aiuap dcnda2=NOPASSWD:/usr/sbin/useradd,/usr/sbin/userdel,/usr/sbin/usermod,/usr/bin/passwd,/usr/sbin/groupadd,/usr/sbin/groupdel,/bin/cat
unionmon ALL=(root) NOPASSWD:/usr/sbin/dmidecode,/usr/sbin/hwinfo, /usr/sbin/hbanyware/hbacmd,/usr/sbin/lsof,/sbin/ethtool,/sbin/mii-tool
_______________请确认SSH文件被正确修改_______
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
_______________请确认unionmon用户PATH被正确修改_______
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/sbin:/usr/bin
export PATH
unset USERNAME
export LANG=en.US
------------------------------------------------------------------------------
正在删除原始authorized_keys,请稍后....
------------------------------------------------------------------------------
------------------------------------------------------------------------------
恭喜您安装成功!
转载于:https://blog.51cto.com/erikxue/1352615