尝试SSH时设备不正确的ioctl [英] Inappropriate ioctl for device when trying to SSH
问题描述
我正在尝试SSH少量服务器,并尝试获取每个服务器的 sudo -l </code>输出.
I'm trying to SSH few servers and trying to get sudo -l
output of each server.
下面是我正在执行的脚本
Below is the script I'm executing
#!/bin/bash
serverlist="/tmp/servers"
while IFS=, read -r server netgroup username user
do
ssh -tt -q root@$server sudo -U $username -l < /dev/null
done < "$serverlist"
我发现此脚本中的 -tt
选项是导致此错误的原因.有什么想法吗?
I have found that -tt
option in this script as the cause of this error. Any thought on this?
我还注意到当我仅对1台服务器执行以下命令时,我没有看到此错误.
Also i have noted that I don't see this error when i execute below command just for 1 server.
ssh -tt -q root @ myserver sudo -U cham01 -l </code>
ssh -tt -q root@myserver sudo -U cham01 -l
以下是我收到的完整错误消息: tcgetattr:设备的不适当的ioctl
Below is the complete error message I'am getting:
tcgetattr: Inappropriate ioctl for device
推荐答案
tcgetattr:设备的不适当的ioctl
通常意味着某些程序试图执行终端控制操作,但是它的标准I/O流未连接到终端.(我知道这一点是因为 tcgetattr
是C的名称库函数执行终端控制操作.)
tcgetattr: Inappropriate ioctl for device
normally means that some program attempted to do a terminal control operation but its standard I/O streams weren't connected to a terminal. (I know this because tcgetattr
is the name of a C library function that does terminal control operations.)
现在, -tt
选项到 ssh
的全部目的是确保在远程主机上运行的程序已连接到一个终端,然后 stty
打印出 speed 38400波特;行= 0;-brkint -imaxbel
证明它是.这是我在 my 服务器上运行以下命令时得到的:
Now, the whole point of the -tt
option to ssh
is to guarantee that the program run on the remote host is connected to a terminal, and stty
printing out speed 38400 baud; line = 0; -brkint -imaxbel
demonstrates that it was. This is what I get when I run these commands with my servers:
$ ssh myserver stty < /dev/null
stty: 'standard input': Inappropriate ioctl for device
$ ssh -tt myserver stty < /dev/null
speed 38400 baud; line = 0;
-brkint -imaxbel
Connection to myserver closed.
但是你得到的是
$ ssh -tt yourserver stty < /dev/null
tcsetattr: Inappropriate ioctl for device
speed 38400 baud; line = 0;
-brkint -imaxbel
tcsetattr
错误不是来自 stty
的 .首先,某些尝试执行与终端相关的操作的操作失败了,然后然后 stty
成功运行.这表明您的Shell启动脚本中存在一个错误,该错误在非交互式"运行时做了不适当的事情,即使您正在运行 ,也会导致您得到此错误连接到终端的命令.我无能为力,但是
The tcsetattr
error is not coming from stty
. First something tried to do something terminal-related and failed, and then stty
ran successfully.
This suggests a bug in your shell startup scripts, which are doing something that is inappropriate when run "non-interactively", causing you to get this error even though you are running commands connected to a terminal. I can't help you any further, but perhaps this old answer about a similar problem offers some clues.
这篇关于尝试SSH时设备不正确的ioctl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!