unable to connect to my railway service using railway ssh
bruceh29
FREEOP

a day ago

On my project's deployment console tab, I clicked the link for "copy ssh command", then pasted that command into a shell window on my local PC. It fails, with this error:


No SSH keys found in your SSH agent or ~/.ssh/

Generate one with:

ssh-keygen -t ed25519

Then run this command again.


I did exactly that, and I verified that there is an entry in my ~/.ssh directory for that id. Then I ran the same command again, and it fails that way, saying that there are no SSH keys found (even though there is).

How do I fix this?

Awaiting Conductor Response$10 Bounty

6 Replies

Railway
BOT

a day ago

To connect, your key also has to be registered with your Railway account, not only present in ~/.ssh. You can register it with railway ssh keys add --key ~/.ssh/id_ed25519.pub --name "laptop", or run railway ssh keys add with no flags to pick from your local keys. You can check which keys are registered with railway ssh keys.

If the CLI still doesn't detect the key, you can point it straight at the private key with railway ssh -i ~/.ssh/id_ed25519. That skips the local ~/.ssh scan and passes the key directly to ssh. More details are in the railway ssh docs.


Status changed to Awaiting User Response Railway • about 24 hours ago


Railway

To connect, your key also has to be registered with your Railway account, not only present in `~/.ssh`. You can register it with `railway ssh keys add --key ~/.ssh/id_ed25519.pub --name "laptop"`, or run `railway ssh keys add` with no flags to pick from your local keys. You can check which keys are registered with `railway ssh keys`. If the CLI still doesn't detect the key, you can point it straight at the private key with `railway ssh -i ~/.ssh/id_ed25519`. That skips the local `~/.ssh` scan and passes the key directly to `ssh`. More details are in the [railway ssh docs](https://docs.railway.com/cli/ssh).

bruceh29
FREEOP

a day ago

Attempting to register the key using "railway ssh keys add", with or without the --key specified, does not work. It returns the exact same error, saying "No SSH keys found in your SSH agent or ~/.ssh/". But it is in fact present, in my ~/.ssh directory.

Also, specifying the explicit key in the command line (as you suggested, "railway ssh -i ~/.ssh/id_ed25519") does not work either. That appears to connect initially, but there is a message that comes back which includes the string "This SSH key isn't linked t

o a Railway account yet."


Status changed to Awaiting Railway Response Railway • about 23 hours ago


Railway
BOT

a day ago

The "This SSH key isn't linked to a Railway account yet" message means the connection is working and the only missing step is getting the public key registered, so you can skip the CLI's local key scan entirely.

The simplest way is to open the SSH keys page in your Account Settings in the dashboard and paste in the contents of ~/.ssh/id_ed25519.pub (the .pub file, not the private key). If that key is also on your GitHub account, railway ssh keys github imports it instead. After that, railway ssh keys should list it, and the copied SSH command or railway ssh -i ~/.ssh/id_ed25519 will authenticate with it.

More details are in the railway ssh docs.


Status changed to Awaiting User Response Railway • about 23 hours ago


Railway

The "This SSH key isn't linked to a Railway account yet" message means the connection is working and the only missing step is getting the public key registered, so you can skip the CLI's local key scan entirely. The simplest way is to open the SSH keys page in your Account Settings in the dashboard and paste in the contents of `~/.ssh/id_ed25519.pub` (the `.pub` file, not the private key). If that key is also on your GitHub account, `railway ssh keys github` imports it instead. After that, `railway ssh keys` should list it, and the copied SSH command or `railway ssh -i ~/.ssh/id_ed25519` will authenticate with it. More details are in the [railway ssh docs](https://docs.railway.com/cli/ssh).

bruceh29
FREEOP

a day ago

It does work now, but only if I explicitly include "-i ~/.ssh/id_ed25519" on the command line. Using the "Copy SSH command" on the console tab, then pasting that into a shell window as-is, still fails with the error "No SSH keys found in your SSH agent or ~/.ssh/". I don't know why.


Status changed to Awaiting Railway Response Railway • about 23 hours ago


Railway
BOT

a day ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway • about 23 hours ago


Anonymous
FREE

13 hours ago

The remaining error comes from local public-key discovery, before Railway checks whether the key is registered. That explains why registering it fixed -i but did not fix the copied command.

I checked the CLI source and reproduced this with the official v5.63.1 Linux binary and disposable keys. With no key agent available, a valid private id_ed25519 alone still gives your exact error. Adding a valid public half as .ssh/id_ed25519.pub clears that discovery error. An unreadable/invalid public file is silently skipped; the scan also only considers lowercase .pub files directly inside the home directory’s .ssh folder.

Also, railway ssh keys add --key … still runs that same discovery first. Its --key option selects from already-discovered keys; it does not independently load an arbitrary file. So repeating that command cannot repair the discovery failure.

Since your existing private key works with -i, keep it. In the same shell where you run Railway:

  1. Check railway --version, and check the public file with ssh-keygen -l -f ~/.ssh/id_ed25519.pub.
  2. If that public file is missing or invalid, back it up if present, then derive its public half from the working private key using ssh-keygen -y -f ~/.ssh/id_ed25519. Save that output as one plain UTF-8/ASCII line in ~/.ssh/id_ed25519.pub. This reuses your existing key; it does not generate a different identity. Do not share the private key.
  3. Retry the copied command. On Windows, ensure the .ssh folder is in the Windows profile used by railway.exe; a Git Bash/WSL home may be a different location. Avoid saving the public file as UTF-16.

If a valid public file is already there, the next useful details are CLI version, OS/shell, and the resolved public-file path. The thread does not establish which of those local conditions applies yet.

Sources:

Public-file discovery and parsing: https://github.com/railwayapp/cli/blob/1bc05636f79e9d094edcce48e413254c0a1a6c1d/src/controllers/ssh/keys.rs#L94-L184

keys add discovery order: https://github.com/railwayapp/cli/blob/1bc05636f79e9d094edcce48e413254c0a1a6c1d/src/commands/ssh/keys.rs#L271-L316

AI-assisted; the local discovery behavior above was tested with the official binary in an isolated environment. No Railway server connection was part of that test.

Arda


The remaining error comes from local public-key discovery, before Railway checks whether the key is registered. That explains why registering it fixed `-i` but did not fix the copied command. I checked the CLI source and reproduced this with the official v5.63.1 Linux binary and disposable keys. With no key agent available, a valid private `id_ed25519` alone still gives your exact error. Adding a valid public half as `.ssh/id_ed25519.pub` clears that discovery error. An unreadable/invalid public file is silently skipped; the scan also only considers lowercase `.pub` files directly inside the home directory’s `.ssh` folder. Also, `railway ssh keys add --key …` still runs that same discovery first. Its `--key` option selects from already-discovered keys; it does not independently load an arbitrary file. So repeating that command cannot repair the discovery failure. Since your existing private key works with `-i`, keep it. In the same shell where you run Railway: 1. Check `railway --version`, and check the public file with `ssh-keygen -l -f ~/.ssh/id_ed25519.pub`. 2. If that public file is missing or invalid, back it up if present, then derive its public half from the working private key using `ssh-keygen -y -f ~/.ssh/id_ed25519`. Save that output as one plain UTF-8/ASCII line in `~/.ssh/id_ed25519.pub`. This reuses your existing key; it does not generate a different identity. Do not share the private key. 3. Retry the copied command. On Windows, ensure the `.ssh` folder is in the Windows profile used by `railway.exe`; a Git Bash/WSL home may be a different location. Avoid saving the public file as UTF-16. If a valid public file is already there, the next useful details are CLI version, OS/shell, and the resolved public-file path. The thread does not establish which of those local conditions applies yet. Sources: Public-file discovery and parsing: https://github.com/railwayapp/cli/blob/1bc05636f79e9d094edcce48e413254c0a1a6c1d/src/controllers/ssh/keys.rs#L94-L184 `keys add` discovery order: https://github.com/railwayapp/cli/blob/1bc05636f79e9d094edcce48e413254c0a1a6c1d/src/commands/ssh/keys.rs#L271-L316 AI-assisted; the local discovery behavior above was tested with the official binary in an isolated environment. No Railway server connection was part of that test. Arda

bruceh29
FREEOP

4 hours ago

This is very helpful, thank you Arda!!

This is my first time trying something on Railway, and I have to say that all of the setup required is very confusing. So I appreciate the help!


Welcome!

Sign in to your Railway account to join the conversation.

Loading...