【发布时间】:2021-12-30 08:03:40
【问题描述】:
我正在使用一个特定于站点的身份验证脚本,该脚本为无密码登录颁发 24 小时证书。我要做的是装配我的~/.ssh/config,所以ssh 在证书过期时触发脚本:
Match originalhost remotehost.site exec "test $(file.age ~/.ssh/certificate) -ge 86400" exec ~/bin/authentication_script
这几乎有效——它可以测试最新证书文件的年龄,如果它已过期,则调用authentication_script。问题是该脚本使用 TTY read 操作来获取密码输入,并给出以下错误:
stty: 'standard input': Inappropriate ioctl for device
stty: 'standard input': Inappropriate ioctl for device
authentication_script: The sshproxy server said: Authentication failed. Failed login: myname:
authentication_script: This usually means you did not enter the correct password or OTP:
stty: 'standard input': Inappropriate ioctl for device
stty: 'standard input': Inappropriate ioctl for device
stty: 'standard input': Inappropriate ioctl for device
authentication_script: The sshproxy server said: Authentication failed. Failed login: myname:
authentication_script: This usually means you did not enter the correct password or OTP:
stty: 'standard input': Inappropriate ioctl for device
当我从常规登录会话在命令行上运行脚本时,不会发生这种情况。 有什么模式可以翻转来让它工作吗?
【问题讨论】:
-
使用
ssh -t remotehost.site也不起作用。当 I/O 操作通过 ssh-connection 发生时,它可能会解决问题;不过,这里发生的事情是ssh在我的笔记本电脑上本地调用脚本,并且似乎遵循一组不同的重定向规则。 -
脚本使用
read -r -p "Enter the password for ${user}: " -s pw的形式我希望我能以某种方式添加-u fd Read input from file descriptor fd,以将输入重新连接到我的键盘。
标签: stty password-less ssh-config