Linux 询问自定义/别名命令的密码?

标签 linux bash shell passwords command

我正在使用很多alias Linux 中的命令但如何用 p/w 保护每个命令?

可以说我做了:

$ vi .bash_profile
alias goto1='echo ip=192.168.1.1, pw=abc; ssh root@192.168.1.1;'
alias goto2='echo ip=192.168.1.2, pw=xyz; ssh root@192.168.1.2;'

$ source .bash_profile
$ goto1
ip=192.168.1.1, pw=abc
root@192.168.1.1's password: _

这就是基于 Unix/Linux 系统的完美品味。我经常使用这样的东西!
但问题是:

  • 如何保护这些自定义 alias命令 password迅速的?
  • 例如,当我输入$ goto1

有什么好主意吗!?

最佳答案

您可以将这些别名命令添加到( super 用户)/root/.bashrc 文件中。

您可以对想要使用密码或不使用密码运行该命令的普通用户使用“sudo”限制。

http://www.linux.com/learn/tutorials/306766-linux-101-introduction-to-sudo

关于Linux 询问自定义/别名命令的密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14600618/

相关文章:

linux - 运行 shell 脚本以获得正确的进程数

linux - watch 命令的意外行为

android - 安装 ia32-libs 包

linux - 如何将我的 Bash 循环变量传递给 Perl?

shell - makefile 中的“tee”,我们也可以复制 stderr 吗?

linux - 先前命令执行的退出代码始终为 0——在远程 Shell 执行中 $?

linux - 为什么 sed 会因国际字符而失败以及如何修复?

linux - shell中的动态变量

linux - 使用 grep 就像 awk 中的条件一样

bash - Shell 提示符换行问题