Keeping our passwords well secured is something that we all need to take seriously, but what do you do if a particular program or app displays your password in plain sight as you are typing it? Today’s SuperUser Q&A post has the solution to a frustrated reader’s password problem.

保持密码安全性是我们所有人都必须认真对待的事情,但是,如果某个特定的程序或应用在键入密码时能清楚看到密码,您该怎么办? 今天的“超级用户问答”帖子提供了解决沮丧的读者密码问题的方法。

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。

问题 (The Question)

SuperUser reader user110971 wants to know how to keep passwords invisible when running a command as an SSH argument:


If I run this command and start typing the MySQL password, the password is visible on the screen:


  • ssh user@server ‘mysql -u user -p’

    ssh user @ server'mysql -u用户-p'

How can I prevent this? If I log in through SSH and execute the MySQL command, then everything works fine.

我该如何预防? 如果我通过SSH登录并执行MySQL命令,则一切正常。

How can you keep passwords invisible when running a command as an SSH argument?


答案 (The Answer)

SuperUser contributor Toby Speight has the answer for us:

超级用户贡献者Toby Speight为我们提供了答案:

If you provide a remote command to run, SSH does not allocate a tty, so the remote command is unable to disable echo. You can force SSH to provide a tty using the -t option:

如果提供要运行的远程命令,则SSH不会分配tty ,因此远程命令无法禁用echo。 您可以使用-t选项强制SSH提供tty

  • ssh -t user@server ‘mysql -u user -p’

    ssh -t user @ server'mysql -u用户-p'

The equivalent option (for -o or for the config file) is RequestTTY. I would caution against using it in the config file because it can have unwanted effects for non-interactive commands.

等效选项(用于-o或用于配置文件)是RequestTTY 。 我会警告不要在配置文件中使用它,因为它会对非交互式命令产生不良影响

Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程

Image Credit: Linux Screenshots (Flickr)

图片来源: Linux屏幕截图(Flickr)



< <上一篇