SSH "no such identity" and Load key "invalid format"
Both lines mean ssh tried to use a private key at a path it can name, and
could not load it. With no such identity the file is not there.
With Load key ... invalid format the file is there, but ssh could
not read it as a private key. Neither line is a refusal from the server: they
come from the machine you typed the command on.
This page describes standard OpenSSH behaviour. The commands are the usual ones, and wording differs between versions, distributions and platforms. We did not run them on your system for this page.
What the lines mean
no such identity: /home/you/.ssh/work_ed25519: No such file or directory
Load key "/home/you/.ssh/work_ed25519": invalid format
The path comes from somewhere ssh was told to look: a -i option
on the command line, an IdentityFile line in
~/.ssh/config, or another source that the -v output
shows. The first line says nothing exists at that path. The second says
something exists there, but it is not a private key in a form OpenSSH reads.
The words after the colon can differ by version, and a load failure can carry
a different reason than invalid format. This page covers the two
above. If the line instead ends with
incorrect passphrase supplied to decrypt private key, the file is
there and the passphrase was the problem: see
SSH Load key "incorrect passphrase".
These lines are often warnings, not a hard stop. ssh may go on to offer other
keys, from the agent or from other files, and the login can still succeed. If
it does not, the last line you see is usually
Permission denied (publickey), and the earlier line is a clue to why the key you meant was never sent.
Some versions print the missing-file case only at higher verbosity, such as
-vvv, and some word it as a warning about an identity file that
is not accessible.
This is a different message from the ones that sound alike, so confirm that first:
-
WARNING: UNPROTECTED PRIVATE KEY FILE!means the key file exists and is readable by other users, so ssh ignored it. It is covered in SSH "Permission denied (publickey)". -
The agent has no identitiesandCould not open a connection to your authentication agentare about the agent, not about a key file path. They are also on the publickey page. -
Bad owner or permissions on a config file
means ssh would not read
~/.ssh/configat all, so none of its entries applied. - Permission denied (publickey) means a connection was made and login failed. It can follow the lines on this page, but it is a separate problem.
1. Read the path in the message
Copy the path exactly as printed. A ~ or a relative path in your
command or config is shown there after ssh has expanded it, so the message
tells you where ssh really looked. Check the spelling, the directory, the user
whose home it is, and the file name. A key saved as
work_ed25519 is not found if the command says
work_ed25519_old.
Running again with -v shows which key paths ssh tried, and the
ssh -v output reader can check a pasted log
for these lines. It runs in your browser and sends nothing.
ssh -v user@server.example.com
2. See whether the file exists
List the path from the message:
ls -l /home/you/.ssh/work_ed25519
ls -l ~/.ssh
The first command answers the question directly. The second shows what is in
the folder, which helps when the file is there under a slightly different name
or is in another folder. If ls says the file does not exist, the
message was right and step 3 applies. If the file is listed, go to step 4.
3. If it is missing, put the key there or fix the path
There are two ways out, and only one is needed:
- Place the key at that path. Restore the private key from wherever you keep it, such as a backup or another machine, into the path the message names. Do not generate a new key only to fill the gap unless you also put its public half on the device, because a new key is a different identity.
-
Change the path ssh is told to use. Correct the
-ioption in the command, or theIdentityFileline in~/.ssh/config, so it names a file that exists.
ssh -i ~/.ssh/work_ed25519 user@server.example.com
Host server.example.com
User user
IdentityFile ~/.ssh/work_ed25519
If the path in the message is one you never wrote, it may come from a config
entry that matches more hosts than you meant, such as a
Host * block. ssh -G prints the
identityfile values ssh would use for a host, without connecting.
It reads the same client config, so if that config is refused, fix that first
with the bad owner guide.
The ssh -G output reader shows the values
from a pasted copy.
ssh -G myserver | grep -i '^identityfile '
4. If the file exists but will not load
Load key ... invalid format means ssh opened the file and could
not read it as a private key. Check these, in this order:
-
It is the private key you meant. The file ending in
.pubis the public half and is not a private key. A path that points at it, or a file that holds only the public line, is not loadable as one. - It was not cut short. A private key file is a few lines of text between a begin line and an end line. A copy that lost lines or characters when it was pasted, edited or transferred will not load.
-
It was not converted or saved in another form. A key saved
by another tool in its own format, such as a PuTTY
.ppkfile, is not an OpenSSH private key. It needs to be exported or converted to the OpenSSH form with the tool that made it. - It is a key at all. A file that holds something else, such as a web page saved by mistake, will report the same line.
You can look at the first line of the file without printing the whole key. Take care not to paste a private key into a chat, a ticket or a web page. The begin line of an OpenSSH private key names the format, and a key in another form has a different first line.
head -n 1 ~/.ssh/work_ed25519
OpenSSH can also report the public half of a key it can read, which is a safe way to check that a file loads. It asks for the passphrase if the key has one, and prints an error if the file does not load:
ssh-keygen -y -f ~/.ssh/work_ed25519
If the file turns out to be damaged and you have no other copy, it cannot be repaired. You would need a new key pair and its public half added to the device by another route.
5. Retry the same command
Run the same ssh command again. If the key now loads, the earlier
line goes away. If login still fails, the next message is the real one to
read, and it is often
Permission denied (publickey), which covers the account, the key on the device, and how to make ssh offer
only the key you name.
If the machine is a RescueShell device
A path that starts from the device can avoid a public SSH port. The agent on the device keeps an outbound HTTPS connection to our relay, so reaching a shell does not depend on an inbound port on the device. That needs the agent installed and running first.
It does not create or repair a local key file. If you still use that file for a direct connection, a missing or unreadable key stays a problem for that connection. If a shell does not open once the agent is installed, see the shell does not open.
Try it on one device
The first device is free to try with no card, for 30 days from when it connects, not from when you sign up. Start a trial.