Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh-copy-id fails with redirect error #754

Open
tthkbw opened this issue Mar 22, 2024 · 4 comments
Open

ssh-copy-id fails with redirect error #754

tthkbw opened this issue Mar 22, 2024 · 4 comments

Comments

@tthkbw
Copy link

tthkbw commented Mar 22, 2024

ssh-keygen seems to work ok, but when I try to use ssh-copy-id, I get this:

warning: An error occurred while redirecting file '/dev/null` ] || echo >> .ssh/authorized_keys || exit 1; } && cat >> .ssh/authori
zed_keys || exit 1; if type restorecon >/dev/null 2>&1; then restorecon -F .ssh .ssh/authorized_keys; fi'

Any help?

@holzschu
Copy link
Owner

That's a tough one. If I read the source code correctly, that command is executed on the host, so the most likely answer is that the host does not allow redirection to "/dev/null".

@tthkbw
Copy link
Author

tthkbw commented Mar 22, 2024

The host is a MacBook Air M2 running Sonoma 14.3.1. When I execute

echo “hello, dev null” > /dev/null”

On the host, I see no issues.

I am running a-shell on an iPad Pro 12.9 3rd generation running iPadOS 17.4.

I’m pretty sure at one time I had ssh running without requiring a password from a-shell. But for awhile now I haven’t been able to. I hoped that the new ssh-copy-id command would solve my issues.

@holzschu
Copy link
Owner

I tried on my own MacBook Air, and it works. The thing is, ssh-copy-id needs to be able to connect to the other machine (using another ssh key, usually) in order to copy the new ID. If you cannot already connect with ssh, ssh-copy-id will not work.

@tthkbw
Copy link
Author

tthkbw commented Mar 25, 2024

I am able to log in to my MacBook Air from my ipad using a-shell--it just asks for the password. Same for using sftp and other commands.

I think that you are trying this running a-shell on your MacBook??

So I tried that and got the same error. Then I thought, why not try another machine? So I tried using ssh-copy-id while using a-shell on my Air but connecting to my macmini. When I ssh-ed into the macmini first to be sure it worked, I realized that the macmini was using zsh as my shell because it asked to update. I went through the procedure and voila! ssh-copy-id worked perfectly and I could ssh without a password.

My default shell on the Air is fish. Then I realized that this issue probably started after I began using fish as my shell, which was probably shortly after getting the new MacBook Air M2. So, I thought, let's try changing the shell to see it that fixes the problem connecting to the Air.

It did! By changing the default shell to zsh, a-shell's ssh-copy-id does not fail and everything works as expected. Then I changed the default shell back to fish and it still works--which makes sense.

I suspect the failure has something to do with the fact that fish is installed using Homebrew and its path is /opt/homebrew/bin/fish rather that /bin/fish. Why this affects redirects to /dev/null, when fish does support this, I have no idea, but macos does comment that fish shell is a non-standard shell--probably because it does not come with macOS.

Anyway, others may have this issue as well, and I hope they find this solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants