使用本地密钥通过 SSH 连接到跳板机并登录目标主机
ssh -J user@jump_host:jump_port -i ~/.ssh/id_rsa -p dest_port user@destination_host:dest_port
ssh -J root@192.168.0.1:3022 -i ~/.ssh/id_rsa root@192.168.10.1 -p 4022
expect 脚本
#! /usr/bin/expect -fset jump_port 3022set jump_user rootset jump_host 192.168.0.1#set jump_passwdset timeout 30set dest_host 192.168.10.1set dest_user rootset dest_port 4022set private_key ~/.ssh/id_rsaspawn ssh -o "ProxyJump=$jump_user@$jump_host:$jump_port" $dest_user@$dest_host -p $dest_port#expect {# "yes/no" {# send "yes\n"# expect "password"# send "$passwd\n"# }# "*assword" {# send "$passwd\n"# }#}interact