linux - 如何自动将答案传递给命令行

标签 linux bash git ubuntu unix

这个问题在这里已经有了答案:





How can I save username and password in Git?

(28 个回答)


4个月前关闭。




尝试自动化我的 github 身份验证
每当我运行 git push它要求我提供用户名和身份验证
enter image description here
我想自动化它抛出脚本,这样每当它要求用户名时,我的脚本就会通过它
注意:即使是 git push 命令也是通过脚本自动执行的
这是我使用脚本自动化 git push 的方法

read -p "Do you want to push changes? (y/n)" push_choice 
if [ "$push_choice" == "y" ];
then
git push
它不止于此,但在代码命中 git push 命令后,它会要求我输入密码和用户名。
那么这个脚本有什么方法可以传递它需要的所有信息,因为每次它要求相同的用户名并通过

最佳答案

使用带有公钥身份验证的 SSH 而不是密码。
参见例如
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh

关于linux - 如何自动将答案传递给命令行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71142844/

相关文章:

c++ - 在 Linux 上使用 libserial 从串行端口读取额外字符

linux - 在 root 模式下无法使用 pip3.5

linux - 使用 xCode 的 Linux 初学者编程?

git - PhpStorm 是否有内置的 git 修订图?

Cygwin:制造问题

bash - 如何在 SWI-Prolog 控制台中使用上/下历史记录键?

linux - 使用管道时类似于字符串操作的基本名称

bash - 在 bash 脚本中向 git 提供密码

git - 我可以查看每个存储条目到底包含什么内容吗?

linux - 使用 git pull 和 git push 命令的 origin master 和 origin/master 之间的区别