SSH Key - Still asking for password and passphrase

SSH Key - Still asking for password and passphrase

回答1

Add Identity without Keychain

There may be times in which you don't want the passphrase stored in the keychain, but don't want to have to enter the passphrase over and over again.

You can do that like this:

ssh-add ~/.ssh/id_rsa 

This will ask you for the passphrase, enter it and it will not ask again until you restart.

Add Identity Using Keychain

As @dennis points out in the comments, to persist the passphrase through restarts by storing it in your keychain, you can use the -K option (-k for Ubuntu) when adding the identity like this:

ssh-add -K ~/.ssh/id_rsa

Once again, this will ask you for the passphrase, enter it and this time it will never ask again for this identity.

 

评论:

Note that this won't persist the identity on restarts. You can use the -K option to store the passphrase in your keychain when adding it, e.g. ssh-add -K ~/.ssh/id_rsa

– Dennis

Oct 27 '15 at 10:23

 

回答2

If you work with HTTPs urls, it'll always ask for your username / password.

If you're correctly using SSH when cloning / setting remotes. Then make sure you have a ssh-agent to remember your password. That way, you'll only enter your passphrase once by terminal session.

If it is still too annoying, then simply set a ssh-key without passphrase.

评论:

I just want to note that passphrases are used to encrypt your private key, so if you don't use a passphrase, then your private key will be unencrypted on your machine. It's like leaving a password in a text file laying around on your computer.
– user456814
Jul 5 '14 at 17:25

 

回答3

If you're using windows, this worked for me:

eval `ssh-agent -s`
ssh-add ~/.ssh/*_rsa

It'll ask for passphrase in the second command, and that's it.

 

How to avoid being asked passphrase each time I push to Bitbucket

回答1

You need to use an ssh agent. Short answer: try

$ ssh-add

before pushing. Supply your passphrase when asked.

If you aren't already running an ssh agent you will get the following message:

Could not open a connection to your authentication agent.

In that situation, you can start one and set your environment up thusly

eval $(ssh-agent)

Then repeat the ssh-add command.

It's worth taking a look at the ssh agent manpage.

 

回答2

 

Create (or edit if it exists) the following ~/.ssh/config file:

Host *
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa

 

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(50)  评论(0编辑  收藏  举报
编辑推荐:
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
阅读排行:
· 【.NET】调用本地 Deepseek 模型
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
历史上的今天:
2019-10-22 Sequence contains no elements
2015-10-22 Add docking and floating support easely and quickly with DockExtender
2015-10-22 tcp断开的4次挥手
2015-10-22 tcp连接的3次握手
2015-10-22 WireShark
2014-10-22 excel的C#操作教程
2014-10-22 Excel编程的基本概念
点击右上角即可分享
微信分享提示