使用Windows PowerShell设置.SSH键时出错

编程入门 行业动态 更新时间:2024-10-25 10:30:54
本文介绍了使用Windows PowerShell设置.SSH键时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的Git BASH shell可以正常使用SSH密钥,所以我知道我的基本配置步骤是正确的,但我更喜欢windows powershell(实际上我更喜欢Mac或Linux终端,但是没有可用的选项。 ..)

无论如何。

我的Windows PowerShell是在PS1脚本文件中设置的 markembling.info/2009/09/ssh-agent -in-powershell 和我所知道的,启动运行正常

启动SSH代理.. 。 SSH代理程序PID:5064

但是当我尝试SSH或运行git命令从powershell,我仍然提示输入密码。有没有人见过这个?我更喜欢PS给Git Bash,但会在最糟糕的情况下继续使用它。

编辑 - VonC提供的答案= Add%HOME%to windows系统环境变量

查看或更改环境变量: 右键单击我的电脑,然后然后单击属性。 单击高级选项卡。 单击环境变量。 在用户变量下单击以下选项之一:单击新建变量名称`HOME`(不包含引号或百分号)值:C:\文档和设置\ **你的用户名**

重新启动powershell(或者你喜欢的任何shell)和你的SSH工程 / code>。 它可能自然地设置在bash会话中,但在Windows(这里是PowerShell)会话中,它没有默认定义。

最好在用户环境变量级别定义该变量,以便从中继承所有shell。

I've got the GIT BASH shell working correctly with SSH keys, so I know my basic configuration steps are correct, but I prefer the windows powershell (actually I prefer the Mac or Linux terminal, but out of the available options...)

Anyways.

My windows powershell is set up with the PS1 script fount in this blog post markembling.info/2009/09/ssh-agent-in-powershell and from what I can tell, the start up is running correctly

Starting SSH agent... SSH agent PID: 5064

But when I try to SSH in or run git commands from powershell, I'm still prompted for a password. Has anyone seen this before? I prefer PS to Git Bash but will stick with it in the worst case.

EDIT - Answer provided by VonC = Add %HOME% to windows system environment variables

To view or change environment variables: Right-click My Computer, and then click Properties. Click the Advanced tab. Click Environment variables. Click one the following options, under user variables: Click New variable name `HOME` (No quotes, or percentage signs) value: C:\Documents and Settings\**your username**

Restart powershell (or whatever shell you love) and your SSH works by default.

解决方案

The first element to check is the value of the environment variable %HOME%. It might be naturally set in a bash session, but in a Windows (here PowerShell) session, it is not defined by default.

It is best to defined that variable at the "User Environment Variables" level, for all shells to inherit from it.

更多推荐

使用Windows PowerShell设置.SSH键时出错

本文发布于:2023-07-20 22:09:01,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Windows   PowerShell   SSH

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!