这样启动sshd经常断掉,需要后台启动
先使用expect输入密码:
[root@test3 ~]# cat hadin_67_channel.sh
!/usr/bin/expect -f
spawn ssh -N -f -L 0.0.0.0:11001:10.214.10.67:22 hadin_analysis_user@10.214.10.67
expect “assword:”
send “**\r”
expect eof
然后使用setsid 后台启动 setsid ./hadin_67_channel.sh
查看:
ps -ef|grep 11001
root 5640 1 0 17:17 ? 00:00:00 ssh -N -f -L 0.0.0.0:11001:10.214.10.67:22 hadin_analysis_user@10.214.128.67
root 5690 1 0 17:18 ? 00:00:00 ssh -N -f -L 0.0.0.0:11001:10.214.10.67:22 hadin_analysis_user@10.214.128.67
root 6396 1 0 17:23 ? 00:00:00 ssh -N -f -L 0.0.0.0:11001:10.214.10.67:22 hadin_analysis_user@10.214.128.67
root 6857 6153 0 17:26 pts/1 00:00:00 grep –color=auto 11001
[root@haidintest1 ~]# ssh -p 11001 hadin_analysis_user@haidintest3
hadin_analysis_user@hadintest3’s password:
Last login: Wed May 24 17:20:41 2017 from 003.idc..net
sh-4.2$ ifconfig
bond0: flags=5187