ssh_key免密钥登陆
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
发送密钥
ssh-copy-id -i .ssh/id_dsa.pub "-p 22 [email protected]"
登录即执行这里面的脚本(注意要指定不等于root)
/etc/profile.d
跳板机主机:
192.168.1.50 要连的主机
192.168.1.230 跳板机
跳板机脚本:
[root@docker7 zxw]# cat jump_ser.sh
#!/bin/bash
function trapper(){
trap '' INT QUIT TSTP TERM HUP
}
function menu(){
cat <<-EOF
=============Host List============
+ 1)192.168.1.50 +
+ 2)192.168.1.51 +
+ 3)192.168.1.52 +
+ 4)exit +
==================================
EOF
}
function host(){
case "$1" in
1)
ssh -p 22 [email protected]
;;
2)
ssh -p 22 [email protected]
;;
3)
ssh -p 22 [email protected]
;;
4|*)
exit
esac
}
function main(){
while true
do
trapper
clear
menu
read -p "Please Input Num:" num
host $num
done
}
main
跳板机安全应用
1、禁止外网登陆,只能内网登陆
2、ssh密码登陆禁用,只能密钥登陆
修改etc/ssh/sshd_config
PasswordAuthentication yes 改为NO
标签:function,跳板,22,192.168,1.50,ssh,搭建 From: https://www.cnblogs.com/yeahzxw/p/16846958.html