权限被拒绝(公钥、键盘交互)

发布于 2024-09-05 23:40:16 字数 231 浏览 1 评论 0原文

当我尝试从 Perl 进行 cvs 签出时,权限被拒绝(公钥、键盘交互)出现此错误。

有什么问题以及如何解决这个问题?

代码:

system ( "CSVROOT:--- CVSRSH:--- cvs co a ");

# i have proper value in cvs root and cvs rsh .

它单独运行并使用 ssh 密钥

Permission denied (publickey,keyboard-interactive) got this error while i am trying to cvs checkout from perl.

what is issue and how to reslove this ?

Code :

system ( "CSVROOT:--- CVSRSH:--- cvs co a ");

# i have proper value in cvs root and cvs rsh .

its running alone and using ssh key

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

活泼老夫 2024-09-12 23:40:16

诊断错误的步骤:

  • 您是否使用 SSH 密钥?
  • 该密钥有密码吗?
  • 当你手动运行时它有效吗?
  • 该脚本是否以与手动运行脚本时相同的用户身份运行?
  • 脚本运行的环境与手动运行时的环境相同吗? (例如,cron 作业不在同一环境下运行)

如果您认为所有答案都是肯定的,那么最后一个答案很可能实际上是否定的。如果脚本是从诸如 cron 之类的调度程序运行的,那么它很可能不会在与手动运行它时相同的环境中运行。我通常解决这个问题的方法是在调度程序和 Perl 脚本之间使用 shell 脚本:

#!/bin/bash

source /home/USERNAME/.profile

#set any other environment variables it needs like

export CSVROOT=:pserver:USERNAME@HOST:/path/to/repo
export CVSRSH=ssh

/path/to/perl/script/script.pl

Steps to diagnose the error:

  • Are you using an SSH key?
  • Does that key have a passphrase?
  • Does it work when you run it by hand?
  • Is the script running as the same user as when you run it by hand?
  • Is the script running under the same environment as when you run it by hand? (e.g. cron jobs do not run under the same environment)

If you think all of the answers are yes, then most likely the last answer is really no. If the script is running from a scheduler like cron it most likely does not run with the same environment as when you run it by hand. The way I normally solve this is to use a shell script between the scheduler and the Perl script:

#!/bin/bash

source /home/USERNAME/.profile

#set any other environment variables it needs like

export CSVROOT=:pserver:USERNAME@HOST:/path/to/repo
export CVSRSH=ssh

/path/to/perl/script/script.pl
情痴 2024-09-12 23:40:16

Chas. 提出问题后的后续调查:

  • 该命令通常在 /bin/sh 或其他 shell 下运行吗?
    要进行测试,请执行 /bin/sh 命令启动 Bourne shell 并再次手动尝试该命令。
    我不熟悉“CVSROOT:---”符号 - 这是否意味着设置 CVSROOT 环境变量?在 Bourne shell 中,通常使用“=”完成,从未见过使用“:”。

  • 该命令在手动运行时是否需要您输入一些内容?我从未见过 cvs co 这样做,但我不将它与 ssh 一起使用。

  • 尝试在命令末尾添加重定向,并在运行后查看文件中的内容:

    system ( "CSVROOT:--- CVSRSH:--- cvs co a > /tmp/log_cmd 2>&1");

Follow-up investigations after Chas.'s questions:

  • Does that command normally run under /bin/sh or some other shell?
    To test, execute /bin/sh command to start Bourne shell and try the command by hand again.
    I'm not familiar with "CVSROOT:---" notation - is that meant to set CVSROOT environmental variable? In Bourne shell it's usually done using "=", never saw ":" used.

  • Does the command, when run by hand, expect some input from you? I never saw cvs co to do so, but I don't use it with ssh.

  • Try to add a redirect to the end of the command and look what's in the file after running:

    system ( "CSVROOT:--- CVSRSH:--- cvs co a > /tmp/log_cmd 2>&1");

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文