我如何通过CS50提供的GitHub Codespace进行SSH登录。

huangapple go评论75阅读模式
英文:

How do I SSH into github codespace provided by CS50

问题

我有一个由CS50提供的codespace。我想要使用我的本地终端通过ssh连接到它。我安装了github-cli。
当我运行 gh cs list 时,它显示了这个codespace:

NAME                                                     DISPLAY NAME            REPOSITORY       BRANCH  STATE      CREATED AT
roshanpaudel111-literate-space-sniffle-g6x64ww79x9cvgg9  literate space sniffle  code50/65642985  main    Available  6d

但是当我尝试使用这个命令进行ssh连接时 gh cs ssh roshanpaudel111-literate-space-sniffle-g6x64ww79x9cvgg9,它显示以下输出:

? Choose codespace: code50/65642985 (main): literate space sniffle
ubuntu@localhost: Permission denied (publickey,password).
shell closed: exit status 255

我该如何解决这个问题?
整个过程如下:

linux@linux ~ $ gh cs list
NAME                                                     DISPLAY NAME            REPOSITORY       BRANCH  STATE      CREATED AT
roshanpaudel111-literate-space-sniffle-g6x64ww79x9cvgg9  literate space sniffle  code50/65642985  main    Available  6d
linux@linux ~ $ gh cs ssh roshanpaudel111-literate-space-sniffle-g6x64ww79x9cvgg9
? Choose codespace: code50/65642985 (main): literate space sniffle

ubuntu@localhost: Permission denied (publickey,password).
shell closed: exit status 255
linux@linux ~ [1] $
英文:

I have a codespace provided by CS50. I want to ssh into it using my local terminal. I installed github-cli.
When I run gh cs list It shows the codespace :

NAME                                                     DISPLAY NAME            REPOSITORY       BRANCH  STATE      CREATED AT
roshanpaudel111-literate-space-sniffle-g6x64ww79x9cvgg9  literate space sniffle  code50/65642985  main    Available  6d

But when I try to ssh into it using this command gh cs ssh roshanpaudel111-literate-space-sniffle-g6x64ww79x9cvgg9, it shows the following output:

? Choose codespace: code50/65642985 (main): literate space sniffle
ubuntu@localhost: Permission denied (publickey,password).
shell closed: exit status 255

How can I solve this issue?
The whole process looks like this :

linux@linux ~ $ gh cs list
NAME                                                     DISPLAY NAME            REPOSITORY       BRANCH  STATE      CREATED AT
roshanpaudel111-literate-space-sniffle-g6x64ww79x9cvgg9  literate space sniffle  code50/65642985  main    Available  6d
linux@linux ~ $ gh cs ssh roshanpaudel111-literate-space-sniffle-g6x64ww79x9cvgg9
? Choose codespace: code50/65642985 (main): literate space sniffle

ubuntu@localhost: Permission denied (publickey,password).
shell closed: exit status 255
linux@linux ~ [1] $

答案1

得分: 1

请确认您在GitHub Codespaces中注册的私钥格式。

它应该以-----BEGIN OPENSSH PRIVATE KEY-----开头,并以-----END OPENSSH PRIVATE KEY-----结尾(表示非加密的私钥)。
该文件中使用的行尾(end of lines)应为LF(而不是Windows的CRLF),尽管如果您直接复制粘贴其内容,应该没问题。

还请参考cs50/codespace问题62中的步骤

OP Rosan Paudel评论中补充说:

我认为它适用于我们手动创建的codespaces。
我尝试通过cs50提供的存储库中的codespace进行ssh连接。
每当我运行update50时,它会搞乱一切。所以我不得不放弃做任何调整。

英文:

Double-check the format of the private key you registered in GitHub Codespaces.

It should start with -----BEGIN OPENSSH PRIVATE KEY----- and ends with -----END OPENSSH PRIVATE KEY----- (meaning a non-encrypted private key)
The EOL (end of lines) used in that file should be LF (not the Windows CRLF), although if you copy-pasted its content directly, it should be fine.

See also the process followed in cs50/codespace issue 62.


The OP Rosan Paudel adds in the comments:

> I think it works with the codespaces that we create manually.
I was trying to ssh into a codespace that is provided by cs50 which is in my repository.
Whenever I run update50 it screws up everything. So I have to backoff doing any tweaks.

huangapple
  • 本文由 发表于 2023年1月9日 19:36:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/75056717.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定