I am trying to clone a remote repository on Windows, but when I did this:
git clone git@github.com:organization/xxx.git
I got this error:
error: cannot run ssh: No such file or directory
fatal: unable to fork
Am I missing something?
Gino Mempin
22.9k27 gold badges91 silver badges119 bronze badges
asked Sep 24, 2012 at 17:09
Check if you have installed ssh-client
. This solves the problem on docker machines, even when ssh keys are present:
apt-get install openssh-client
ssi-anik
2,6872 gold badges21 silver badges51 bronze badges
answered May 30, 2018 at 0:18
pablorskpablorsk
3,6151 gold badge29 silver badges35 bronze badges
1
You don’t have ssh installed (or don’t have it within your search path).
You can clone from github via http, too:
git clone http://github.com/organization/xxx
answered Sep 24, 2012 at 17:11
MarkMark
6,0031 gold badge18 silver badges14 bronze badges
3
Most likely your GIT_SSH_COMMAND
is referencing the incorrect public key.
Try:
export GIT_SSH_COMMAND="ssh -i /home/murphyslaw/.ssh/your-key.id_rsa
then
git clone git@github.com:organization/xxx.git
Rob♦
27k15 gold badges83 silver badges96 bronze badges
answered Jun 28, 2017 at 6:17
rivanovrivanov
1,17617 silver badges19 bronze badges
1
I am aware that it is an old topic, but having this problem recently, I want to bring here what I resolve my issue.
You might have this error on these conditions :
- You use a URL like this :
git@github.com:organization/repo.git
- And you run a kind of command like this directly :
git clone git@github.com/xxxxx.git
whereas you don’t have ssh client (or it is not present on path) - Or you have an ssh client installed (and
git clone xxx.git
work fine on direct command line) but when you run the same kind of command through a shell script file
Here, I assume that you don’t want to change protocol ssh git@
to http://
(git@github.com:organization/repo.git
-> http://github.com/organization/repo.git
), like my case, cause I needed the ssh
format.
So,
- If you do not have ssh client, first of all, you need to install it
- If you have this error only when you execute it through a script, then you need to set
GIT_SSH_COMMAND
variable with your public ssh key, in front of your git command, like this :
GIT_SSH_COMMAND="/usr/bin/ssh -i ~/.ssh/id_rsa" git pull
(Feel free to change it depending on your context)
answered Mar 3, 2021 at 12:02
MahefaMahefa
4183 silver badges12 bronze badges
1
I had this issue right after my antivirus moved the cygwin ssh binary to virus vault, and restored it after.
Symptoms:
- SSH seems properly installed
- SSH can be run from command line without problem
Another option before reinstalling ssh in this particular case: check the ssh
command permissions
$ ls -al /usr/bin/ssh.exe
----rwxrwx+
$ chmod 770 /usr/bin/ssh.exe
answered Nov 28, 2018 at 11:43
user1556814user1556814
6136 silver badges19 bronze badges
You can try these as well
ssh-add ~/.ssh/identity_file
chmod 400 ~/.ssh/identity_file
answered Nov 3, 2021 at 8:36
It so happened in my case that the new pair of ssh keys linked with my git account were not accessible.
I had to sudo chmod 777 ~/.ssh/id_rsa.*
to resolve the issue.
answered Mar 23, 2022 at 12:26
Dota2Dota2
4364 silver badges15 bronze badges
Windows 10 20H2, build 19042.685
I’m trying to use the SSH agent in the built-in OpenSSH client on Windows 10. The agent is running:
C:UsersDaniel> Get-Service | ?{$_.Name -like '*ssh-agent*'}
Status Name DisplayName
------ ---- -----------
Running ssh-agent OpenSSH Authentication Agent
However, ssh-add
is still throwing the same error:
C:UsersDaniel> ssh-add C:UsersDaniel.sshid_ed25519
Error connecting to agent: No such file or directory
Any ideas?
asked Dec 26, 2020 at 19:13
Daniel Lo NigroDaniel Lo Nigro
4341 gold badge6 silver badges10 bronze badges
1
I found that something in Windows10 is setting the path to ssh-agent as an env-var, but cannot cope with spaces in foldernames. Someone forgot to escape their inputs! (AAAAAAAARRRRGGGGH!).
To test: (in git-bash, which I’m currently using)
echo "$(ssh-agent)"
…gives what your env has setup (in my case: stupidly) for how it will find/access ssh-agent. I got:
SSH_AUTH_SOCK=/d/Windows10 Temporary Files/ssh-XXXXXXX/agent.YYYYY; export SSH_AUTH_SOCK;
SSH_AGENT_PID=54456; export SSH_AGENT_PID;
echo Agent pid 54456;
…oh look! Someone forgot that folders can have spaces, and didn’t bother to escape their inputs (the first line is corrupt, it includes the «export» command).
Re-exporting that env-variable correctly (wrap the «/d/…YYYY» with single quotes, remove the trailing «;», and remove the «export SSH_AUTH_SOCK;» part) causes ssh-agent to work properly again.
answered Feb 4, 2021 at 17:30
Содержание
- Damir’s Corner .
- Using Git with SSH in Windows 10
- How do I make ssh-add recognize the running ssh-agent service with Microsoft’s OpenSSH?
- Can no longer use ssh-add: Error connecting to agent #1781
- Comments
- dom-devel commented May 23, 2018
- Purpose of the issue
- Description of the issue
- lneveu commented May 23, 2018
- raulfragoso commented May 23, 2018
- Stanzilla commented May 24, 2018
- lneveu commented May 24, 2018
- raulfragoso commented May 24, 2018
- dom-devel commented May 25, 2018
- SiqiLu commented Jun 2, 2018
- johncrim commented Oct 31, 2018
- Stanzilla commented Oct 31, 2018
- scottfalkingham commented Nov 13, 2018 •
- EnverOsmanov commented Feb 19, 2019
- tomsseisums commented Mar 13, 2019
- upugo-dev commented Apr 17, 2019
- squaricdot commented Jun 26, 2019
- Error connecting to agent: no such file or directory — adding key to ssh agent
- 7 Answers 7
- ssh-add returns with: «Error connecting to agent: No such file or directory»
- 4 Answers 4
Damir’s Corner .
Using Git with SSH in Windows 10
Although Git can be used over HTTPS with username and password authentication, it’s much more convenient to use over SSH. Even with Git Credential Manager for Windows being bundled with Git for Windows.
First, generate your SSH key. Although you can transfer key files between computers, I suggest generating a new one on each computer you use.
Then, associate the generated key with your Windows login by adding it to the OpenSSH Authentication Agent service.
In my case, the service was disabled and the command failed with the following error:
Error connecting to agent: No such file or directory
The documentation suggested trying to start the service:
For me, it just failed with a different error:
Start-Service : Service ‘OpenSSH Authentication Agent (ssh-agent)’ cannot be started due to the following error: Cannot start service ssh-agent on computer ‘ .’.
To resolve the issue, I had to change the service startup type from Disabled to Automatic in its properties dialog (and start the service then).
With that, the command-line Git client is ready to be used with SSH.
UI clients will typically require additional configuration which is application dependant. In my favorite UI client Fork, this can be done in the File > Configure SSH Keys dialog.
Of course, the contents of the generated SSH public key file (with .pub extension, e.g. id_rsa.pub ) must be added to your account for the Git service provider. Add the same key to all services, if you use multiple.
The location of the relevant settings differs between the Git services:
- In GitHub, it’s in the SSH and GPG keys section of Personal settings.
- In GitLab, it’s in the SSH Keys section of User Settings.
- In Bitbucket, it’s in the SSH keys section of your Bitbucket settings. URL is different for different users.
- In Azure DevOps, it’s in the SSH public keys section of User settings. URL is different for different users.
Make sure that you use the SSH URL instead of the HTTPS one when cloning new repositories (it’s the one not starting with https ).
Источник
How do I make ssh-add recognize the running ssh-agent service with Microsoft’s OpenSSH?
In the course of trying to accomplish a more complicated task (involving hardware security keys and GPG keys for SSH authentication), I have run into an ornery ssh-add utility on my Windows 10 machine. Quite simply, my ssh-add fails to connect to the agent, while all other ssh functions work fine.
When I run ssh-add -L on Powershell 7.0.3, I get the following output:
However, my ssh-agent service seems to be running just fine:
Furthermore, I have my standard public/private SSH keypair in the default location ( C:Users[me].sshid_rsa , C:Users[me].sshid_rsa.pub ). I’ve used this key extensively on GitHub, and ssh itself still works fine in Powershell:
So, given every other aspect of OpenSSH seems to be working fine, why would ssh-add be misbehaving?
Things I have tried to repair it:
- Removing other SSH utilities from my PATH (e.g. those added by Git installation).
- Disabling/re-enabling the Windows optional feature «SSH Client» (and its «SSH Server» counterpart, which I don’t think I need).
- Installing a more recent version of OpenSSH via Chocolatey (https://chocolatey.org/packages/openssh), and pointing all commands to that installation via PATH modification.
- Backing up and removing my .ssh folder, generating a new key (via ssh-keygen ), and starting from scratch.
- Changing the startup type of the ssh-agent service between automatic, manual, and disabled
None of the aforementioned activities seemed to have any effect whatsoever. All other ssh tools worked fine (assuming the optional feature was enabled, and service was running), but ssh-add did not.
What other recommendations do others have for diagnosing this ornery utility?
Источник
Can no longer use ssh-add: Error connecting to agent #1781
Purpose of the issue
- Bug report (encountered problems/errors)
- Feature request (request for new functionality)
- Question
Description of the issue
Can no longer add ssh keys using ssh-add. Instead I’m thrown the following error:
Error connecting to agent: No such file or directory
I believe this has started happening since the latest Windows update.
My set-up
I’m currently booting an ssh-agent at startup, having un-commented before:
- Windows 10
- Latest preview/alpha
Further debugging
I took a look at the environment variables set:
- SSH_AUTH_SOCK: /tmp/ssh-yzpgZ44bVaMU/agent.17940
- SSH_AGENT_PID: 4304
Which correctly creates into:
I tried setting, SSH_AUTH_SOCK to the full windows path above, however at this point I then get:
Could not add identity «.sshid_rsa»: invalid format
Apologies if this is an issue with ConEmu, I’m not knowledgeable enough to be able to separate the two cleanly.
The text was updated successfully, but these errors were encountered:
Same issue here after the latest Windows update :/
(with ConEmu version 161206)
Same issue, with latest version (180506)
try which ssh-agent Windows 1803 comes with their own OpenSSH version by default now, you probably want to remove that from PATH
Thanks @Stanzilla! I removed %SYSTEMROOT%System32OpenSSH from my PATH and it’s working fine now 🙂
Thanks @Stanzilla ! Works for me.
Yep that’s worked for me as well. Cheers @Stanzilla!
@Stanzilla Thanks, that’s worked for me.
Another option (possibly better than using another copy of openssh) is to use the Windows ssh agent. Check status in powershell:
If the service is disabled, start it and set to manual:
If there’s a reason to use a git version of openssh instead of the windows-installed version, that would be good to know.
We need to support older versions of Windows as well
Instead of removing %SYSTEMROOT%System32OpenSSH from your path, merely add the following to your user-profile.cmd file.
It will add gitusrbin to your path again, but this time it comes before the %SYSTEMROOT%System32OpenSSH entry, which allows the ssh-agent calls to work again.
If you are using default ssh client, you can switch git to use it too (answer was found here):
git config —global core.sshCommand «‘C:WindowsSystem32OpenSSHssh.exe’»
@Stanzilla maybe you could use feature detection to set up default ssh for Windows version that support it or let that be the default and downgrade for non-native ssh?
Instead removing %SYSTEMROOT%System32OpenSSH from you path, merely add the following to your user-profile.cmd file.
This seems like a much better solution than removing native OpenSSH from Windows path, which could have lots of consequences
Thanks @Stanzilla! I removed %SYSTEMROOT%System32OpenSSH from my PATH and it’s working fine now 🙂
where did you remove it. how did it got added in the first place?? by cmder?? why do that if it’s wrong?? why do i need to spend 3 hours to get ssh-agent working with this software??
why do i need to google to many different github issues or PR or whatever to get any insight to enable this. as you might notice i’m going quite mental on this, at least it’s a terrible and experience full of anger
Источник
Error connecting to agent: no such file or directory — adding key to ssh agent
I am trying to add key that I have generated to the ssh agent. Below are my steps
After the key is generated, I am starting the ssh agent and adding it
7 Answers 7
VonC is probably right, in that you need to fix your path, but I was facing the same problem despite using the correct one. In my case, I needed to start ssh-agent for the command to work.
Running the sample commands from GitHub was not working, but, since I had installed OpenSSH, I simply started the pre-installed «OpenSSH Authentication Agent» service, on the Services app, as described in this answer.
This problem is maybe because you have two types of ssh-agent.exe , you can see them in task-manager , one ssh-agent will be from git and other one would be from OpenSSH.
Fix
- End all ssh task from task-manager
- Go to the directory where the key is in your case C:repokey this should be your working directory and then run start-ssh-agent will automatically add your private key to the ssh and you won’t need the ssh-add command .
Imp
- start-ssh-agent will use the ssh from git
- start ssh-agent will use the ssh from OpenSSH
So there can be inconsistencies between the version of ssh you’re using and your keys are added/generated with
Источник
ssh-add returns with: «Error connecting to agent: No such file or directory»
ssh-add alone is not working:
How should I use that tool?
4 Answers 4
You need to initialize the agent first.
You can do this in multiple ways. Either by starting a new shell
or by evaluating the variables returned by ssh-agent in your current shell.
I suggest using the second method, because you keep all your history and variables.
In Windows PowerShell (run as admin):
Check the current status of ssh-agent:
Get-Service | ? <$_.Name -like ‘*ssh-agent*’>| select -Property Name, StartType, Status
Enable the Service if it is disabled:
Set-Service -Name ssh-agent -StartupType Manual
Start the Service:
Add your key as before:
The SSH agent is not running, or the environment variables that it sets are not available in the current environment (most importantly SSH_AUTH_SOCK ), or they are set incorrectly (pointing to a dead agent).
You could start the agent in the current shell session using
or start a new shell session through the agent using
(replace fish with whatever shell you are using). But since you say that you used to be able to use ssh-add without this, it leads me to believe that you’ve accidentally killed the agent (or it has terminated due to some other reason). The error message makes me think that the SSH_AUTH_SOCK environment variable is actually set, but that ssh-add can’t find a valid communication socket at that path.
It would not surprise me if your usual way of doing things would work again if you completely logged out and logged in again, or rebooted the machine.
Источник
I am trying to install an SFTP server on my Windows 10 Machine and I am following this tutorial: http://woshub.com/installing-sftp-ssh-ftp-server-on-windows-server-2012-r2/.
I have already generated the keys and now I am inputting this command on Windows PowerShell (which I run as administrator), but I get an error which I don’t know how to fix:
PS C:OpenSSH-Win64OpenSSH-Win64> .sshd.exe install
__PROGRAMDATA__ssh/sshd_config: No such file or directory
I tried to copy the file sshd_config
inside the ProgramDataSSH
folder but then I got this:
PS C:OpenSSH-Win64OpenSSH-Win64> .sshd.exe install
Extra argument install.
Does anyone know how I could fix this? I appreciate any help, cheers
asked May 29, 2019 at 10:31
That article is probably rather dated. Though I actually do not think that there was ever a version of Win32-OpenSSH that used that command to install. So the article is possibly even completely wrong.
Anyway, check:
- Official installation guide or
- my article on Installing OpenSSH on Windows.
Both show that the command to use is:
powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
answered May 29, 2019 at 10:42
Martin PrikrylMartin Prikryl
20.2k9 gold badges71 silver badges155 bronze badges
Я пытаюсь клонировать удаленный репозиторий в Windows, но когда я это сделал:
git clone git@github.com:organization/xxx.git
Я получил эту ошибку:
error: cannot run ssh: No such file or directory
fatal: unable to fork
Я что-то упускаю?
7 ответы
Проверьте, установили ли вы ssh-client
. Это решает проблему на док-машинах, даже если присутствуют ключи ssh:
apt-get install openssh-client
ответ дан 20 апр.
У вас не установлен ssh (или его нет в пути поиска).
Вы также можете клонировать с github через http:
git clone http://github.com/organization/xxx
Создан 24 сен.
Скорее всего, ваш GIT_SSH_COMMAND
ссылается на неправильный открытый ключ.
Пытаться:
export GIT_SSH_COMMAND="ssh -i /home/murphyslaw/.ssh/your-key.id_rsa
становятся
git clone git@github.com:organization/xxx.git
Создан 28 июн.
Я знаю, что это старая тема, но у меня недавно возникла эта проблема, и я хочу принести сюда то, что я решаю свою проблему.
У вас может быть эта ошибка при следующих условиях:
- Вы используете такой URL:
git@github.com:organization/repo.git
- И вы запускаете такую команду напрямую:
git clone git@github.com/xxxxx.git
тогда как у вас нет клиента ssh (или его нет на пути) - Или у вас установлен ssh-клиент (и
git clone xxx.git
отлично работает в прямой командной строке), но когда вы запускаете команду того же типа через файл сценария оболочки
Здесь я предполагаю, что вы не хотите менять протокол ssh git@
в http://
(git@github.com:organization/repo.git
-> http://github.com/organization/repo.git
), как и мой случай, потому что мне нужно было ssh
формат.
Итак,
- Если у вас нет ssh клиента, в первую очередь его необходимо установить
- Если у вас эта ошибка возникает только при выполнении через скрипт, то вам нужно установить
GIT_SSH_COMMAND
переменная с вашим открытым ключом ssh перед вашей командой git, например:
GIT_SSH_COMMAND="/usr/bin/ssh -i ~/.ssh/id_rsa" git pull
(Не стесняйтесь изменять его в зависимости от вашего контекста)
ответ дан 03 мар ’21, в 12:03
У меня возникла эта проблема сразу после того, как мой антивирус переместил двоичный файл cygwin ssh в хранилище вирусов и восстановил его после этого.
Симптомы:
- SSH вроде правильно установлен
- SSH можно запустить из командной строки без проблем
Еще вариант перед переустановкой ssh в данном конкретном случае: проверить ssh
права доступа к командам
$ ls -al /usr/bin/ssh.exe
----rwxrwx+
$ chmod 770 /usr/bin/ssh.exe
Создан 28 ноя.
Вы можете попробовать и эти
ssh-add ~/.ssh/identity_file
chmod 400 ~/.ssh/identity_file
Создан 03 ноя.
В моем случае так получилось, что новая пара ключей ssh, связанных с моей учетной записью git, была недоступна.
Мне пришлось sudo chmod 777 ~/.ssh/id_rsa.*
для решения проблемы.
ответ дан 23 мар ’22, в 12:03
Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками
windows
git
git-clone
or задайте свой вопрос.
Problem: bastion host IP mismatch on ~/.ssh/known_hosts
I had the known_hosts
file old as the IP address of the bastion changed…
$ ssh 10.82.49.24
ssh_exchange_identification: Connection closed by remote host
Did not give me any information. Looking at the verbose output leads to the same thing:
$ ssh -v 10.82.49.24
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /Users/mdesales/.ssh/config
debug1: /Users/mdesales/.ssh/config line 1: Applying options for 10.82.*.*
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Executing proxy command: exec ssh -q -W 10.82.49.24:22 ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com -i ~/.ssh/xxxconfig-xxxx.pem
debug1: key_load_public: No such file or directory
debug1: identity file ~/.ssh/xxxconfig-xxxx.pem
debug1: key_load_public: No such file or directory
debug1: identity file ~/.ssh/xxxconfig-xxxx.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: permanently_drop_suid: 1647059022
ssh_exchange_identification: Connection closed by remote host
At this point, since it is a proxy to another host through the bastion, I could see the bastion being a problem:
$ ssh ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com -i ~/.ssh/xxxconfig-xxxx.pem
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:Z8X1UlIgQ94BKJ7NA/oQi7v0NL4IlFeO7Ou4j76Zphk.
Please contact your system administrator.
Add correct host key in /Users/mdesales/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/mdesales/.ssh/known_hosts:238
ECDSA host key for ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com has changed and you have requested strict checking.
Host key verification failed.
Solution
Removing the entry on line 238 solved the problem… I could ssh to the bastion and I could ssh to the hosts.
$ vim /Users/mdesales/.ssh/known_hosts
$ ssh ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com -i ~/.ssh/xxxconfig-xxxx.pem
The authenticity of host 'ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com (34.x.x.y)' can't be established.
ECDSA key fingerprint is SHA256:Z8X1UlIgQ94BKJ7NA/oQi7v0NL4IlFeO7Ou4j76Zphk.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com -i ~/.ssh/xxxconfig-xxxx.pem,34.213.y.x' (ECDSA) to the list of known hosts.
********************************************************************************
This is a private computer system containing information that is proprietary
and confidential to the owner of the system. Only individuals or entities
authorized by the owner of the system are allowed to access or use the system.
Any unauthorized access or use of the system or information is strictly
prohibited.
All violators will be prosecuted to the fullest extent permitted by law.
********************************************************************************
Last login: Wed Aug 2 20:35:55 2017 from 10.81.31.115
[ec2-user@ip-10-82-50-142 ~]$
Recently did a fresh install of Windows 10 with all the vital updates and tried to use git fetch
on both cmd
and powershell
but was prompted to enter my ssh key so I tried to run ssh-add
but I got an error saying Error connecting to agent: No such file or directory
so then I tried ssh-agent
and got an error saying unable to start ssh-agent service, error :1058
so what could it be?
A quick scan of Get-Service ssh-agent | select *
showed the following
UserName : LocalSystem
Description : Agent to hold private keys used for public key authentication.
DelayedAutoStart : False
BinaryPathName : C:WindowsSystem32OpenSSHssh-agent.exe
StartupType : Disabled
Name : ssh-agent
RequiredServices : {}
CanPauseAndContinue : False
CanShutdown : False
CanStop : False
DisplayName : OpenSSH Authentication Agent
DependentServices : {}
MachineName : .
ServiceName : ssh-agent
ServicesDependedOn : {}
StartType : Disabled
ServiceHandle : Microsoft.Win32.SafeHandles.SafeServiceHandle
Status : Stopped
ServiceType : Win32OwnProcess
Site :
Container :
I quickly noticed that the StartType
was set to Disabled
. Not sure for what reason? To fix this I had to first change it back to Manual
then start the service again.
Get-Service -Name ssh-agent | Set-Service -StartupType Manual
Start-Service ssh-agent
But it didn’t end here, I also had to instruct git to look for ssh in Windows’ directory
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
So now that git knows where to look for ssh we can now add our private key to the ssh authentiction agent ssh-add
then double checking with ssh-add -l
2048 SHA256:p80/dPfeSzXZPM7ba61214oXCNzMB+v+s/K8gexampleaWzx7Y /home/owo/.ssh/id_rsa (RSA)