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

Executing commands via ssh does not work #3638

Closed
pnadon opened this issue May 18, 2021 · 6 comments
Closed

Executing commands via ssh does not work #3638

pnadon opened this issue May 18, 2021 · 6 comments
Labels

Comments

@pnadon
Copy link

pnadon commented May 18, 2021

Describe the bug
I was trying to run ssh user@myserver "cd /boot && ls -l" , but would get the following error: bash: line 64: exec: cd: not found.

To Reproduce
Steps to reproduce the behavior:

  1. ssh user@myserver "cd /boot && ls -l" (user@myserver being a remote linux server)
  2. resulting error: bash: line 64: exec: cd: not found

Environment details
MacOS 11.3.1 Big Sur

Darwin Phils-MacBook-Pro-2.local 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:47 PDT 2021; root:xnu-7195.101.2~1/RELEASE_X86_64 x86_64
ProductName:	macOS ProductVersion:	11.3.1 BuildVersion:	20E241
Loaded config files: /Users/philippenadon/.config/kitty/kitty.conf

Config options different from defaults:
allow_remote_control y
enable_audio_bell    False
font_family          Fira Code
font_size            13.0

Additional context

Try to reproduce the problem with kitty --config NONE

  • Still produces the same problem.

I also already had this set in my ~/.zshrc, which I believe was supposed to help with using ssh:

if [[ "$TERM" = "xterm-kitty" ]]; then
  alias ssh="kitty +kitten ssh"
fi

Alas, I encountered the issue regardless of if this was set...

I tried searching for existing issues that mentioned this issue, but could not find any. Please let me know if I overlooked something.

@pnadon pnadon added the bug label May 18, 2021
@pnadon
Copy link
Author

pnadon commented May 18, 2021

Running the exact same command in the default terminal app worked successfully.

@kovidgoyal
Copy link
Owner

The terminal has nothing to do with how ssh operates.

@kovidgoyal
Copy link
Owner

And just for reference, if you want to cd and run something, the way to
do it is

ssh whatever sh -c "cd /wherever && run whatever"

@martinetd
Copy link
Contributor

martinetd commented May 18, 2021

ssh whatever "cd /foo && ls" does work.
It's the ssh kitten that breaks it by prepending exec so the command ultimately becomes exec cd /foo && ls which doesn't work as cd is a shell built-in (and even if it did work, ls would never be executed anyway)

To be strictly correct it should look for the default shell as it currently does and interpret arguments with it, I guess... But for non-interactive command there really is no advantage to using the ssh kitten so best advice would probably to not setup the alias and only run it when needed

@pnadon
Copy link
Author

pnadon commented May 18, 2021

Ah that clears things up for me, thank you both for answering.

@kovidgoyal
Copy link
Owner

Ah wasnt clear to me the issue was with the ssh kitten, the original post said the issue occurred with or without the ssh kitten aliases to ssh.

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

No branches or pull requests

3 participants