要解决"awk通过plink和多个服务器跳转无响应"的问题,可以尝试以下解决方法:
~/.ssh/config文件中配置跳转代理。示例如下:Host jumpserver
HostName jumpserver.example.com
User username
IdentityFile ~/.ssh/id_rsa
Host targetserver
HostName targetserver.example.com
User username
IdentityFile ~/.ssh/id_rsa
ProxyJump jumpserver
在上述示例中,jumpserver是跳板服务器,targetserver是目标服务器。通过配置代理跳转连接,可以简化连接过程。
#!/usr/bin/expect -f
set password "your_password"
spawn plink -ssh jumpserver
expect "password:"
send "$password\r"
expect "$ "
send "plink -ssh targetserver\r"
expect "password:"
send "$password\r"
expect "$ "
send "awk '{print $1}' your_file\r"
expect "$ "
send "exit\r"
expect eof
在上述示例中,your_password是跳板服务器和目标服务器的密码,your_file是要执行awk命令的文件。
~/.ssh/authorized_keys文件中。示例如下:# 生成ssh密钥对
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# 将公钥添加到跳板服务器和目标服务器
ssh-copy-id jumpserver
ssh-copy-id targetserver
在完成ssh密钥认证后,就可以直接使用plink命令连接跳板服务器和目标服务器,而无需输入密码。
通过以上解决方法,可以解决"awk通过plink和多个服务器跳转无响应"的问题。根据具体情况选择适合的解决方法。