linux - 在 Bash 脚本中嵌入密码

标签 linux bash shell scp

我正在运行一个测试脚本,其中需要将文件复制到目标嵌入式系统。但是当从脚本运行将文件复制到远程目标系统的命令时,系统提示我输入目标板的管理员密码。我怎样才能使脚本自动化,使脚本自己选择密码(从脚本中),而不必每次运行脚本时都手动输入密码。

脚本片段如下:

scp test.file1 <Target ip-address>:/home/bot21/test/.

Password is prompted when the above command is run.

最佳答案

正确的方法是使用基于 key 的身份验证。 Read about it here .

如果该链接曾经中断,只需用谷歌搜索:“ssh passwordless”或“ssh key authentication”。尽管有 Toby 的评论,但我认为链接到或指导如何自己搜索它比重复别人能比我说得更好、更深入的话要好。

关于linux - 在 Bash 脚本中嵌入密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39242031/

相关文章:

linux - 无法使用 iptables-restore 应用防火墙规则

shell - Perl 用变量替换文件的内容

c - 为什么我不能在busybox中用 '\t'模拟自动补全

linux - 如何对目录中的所有文件执行命令并将每个文件的输出移动到新文件夹?

linux - Bash 脚本检查第一个参数是否存在使用返回语句和变量 $?

linux - 为什么列出 linux 用户时得到空白响应?

linux - 从 OSF/Motif & Xt 迁移到 GTK+

linux - 获取文件夹名并重命名文件名 tr Linux bash

linux alternatives command database(找个名字)

bash - 如何在 shell 脚本中创建别名?