bug: SSH options not properly forwarded with coder gitssh
#19283
-
Is there an existing issue for this?
Current BehaviorWhen using Originally reported in #7816. Relevant Log Outputparsing flags ([gitssh -p 2222 git@server]) for "coder gitssh": unknown shorthand flag: 'p' in -p Expected BehaviorAll SSH options should be forwarded to Steps to ReproduceExecute Environment
Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments
-
Please use |
Beta Was this translation helpful? Give feedback.
-
I just tried, but encountered the same issue: $ coder ssh -p 2222 git@server
parsing flags ([ssh -p 2222 git@server]) for "coder ssh": unknown shorthand flag: 'p' in -p Additionally, I believe
Is there any guidance on how to set it up properly? If I use $ ssh -p 2222 git@server
git@server: Permission denied (publickey). |
Beta Was this translation helpful? Give feedback.
-
@NN708 Looks like you want to connect to a 3rd server by using your Coder workspace as a jump server? Am I right? Can you connect to the server from inside the Coder workspace? Sorry if I am getting it wrong. And I would appreciate it if you could explain the exact use case. |
Beta Was this translation helpful? Give feedback.
-
Yes, I'm using the Coder workspace to develop Ansible playbooks, and I need it to act as a control node for managing other servers.
Yes, currently, |
Beta Was this translation helpful? Give feedback.
-
Since this is about Ansible Playbooks - please review the following hints. Where is Port 2222 in the LISTEN state?Note: Port 2222 in this context appears to be for connecting TO external Ansible-managed servers FROM the Coder workspace, not for connecting to the workspace itself. There is an example in https://www.jeffgeerling.com/blog/2022/using-ansible-playbook-ssh-bastion-jump-host where the port 2222 is discussed for bastion use BUT ONLY IF the Port 2222 is the end-point on the bastion, do not use -p 2222 for 'normal' ssh hosts. If you however need to connect to the Ansible hosts on port 2222 AFTER going through the Workspace's SSH, then .ssh/config files or appropriate -W %h:%p or other methods.
Regarding your other questions which may not be responded to: SSH not using the key/agent:Add SSH configuration for your workspacecoder config-ssh --ssh-option "ForwardAgent=yes" When using ssh commands directly, use -v or -vv to get verbose output, then you see which keys are in use. If the above does not help, then you may need to consider these optionsUse The coder gitssh command does not provide this, however the Agent and Proxy setup may be what is needed. Make sure you've setup the .ssh/config file with the Agent option, and then you should have something like these entries to align with your Ansible setup, the default config-ssh will have coder.* and *.coder setup, but you can add your own if you need more configuration or specific items added. Order your .ssh/config correctly to override (if needed, usually the Coder setup can be used).
# Check your SSH Agent Verify SSH agent is available
List available keys
Add additional keys if needed
### Ansible inventory with Proxy setup
|
Beta Was this translation helpful? Give feedback.
-
@bjornrobertsson Are you an AI? So much info, but nothing actually useful. 😅 |
Beta Was this translation helpful? Give feedback.
-
Not an AI. Our AI is called Blink. But like I pointed out, we're not specifically trained in making Ansible or Proxy Bastion work, however the Ansible documentation and SSH Documentation should get you on track. This is just our 'best effort' to get you on track to a solution. |
Beta Was this translation helpful? Give feedback.
-
OK, but the issue isn't with Ansible (it can be reproduced without Ansible at all), so no need to dive too deep into that. |
Beta Was this translation helpful? Give feedback.
-
Ok, that's not a problem. We can revisit your original message:
The coder gitssh command WILL honor the After adding the ssh key to the remote host's .ssh/authenticated_keys, this should work:
I have just tested after running
Added the key to the remote .ssh/authenticated_keys Then
Tested on Coder 2.23.5 |
Beta Was this translation helpful? Give feedback.
-
It works! I got Ansible to work with this setup: export ANSIBLE_SSH_EXECUTABLE=coder
export ANSIBLE_SSH_ARGS="gitssh -- -C -o ControlMaster=auto -o ControlPersist=60s" @bjornrobertsson Thanks for your help! This solution works perfectly, so I'm closing this issue now. |
Beta Was this translation helpful? Give feedback.
Ok, that's not a problem.
We can revisit your original message:
The coder gitssh command WILL honor the
--
After adding the ssh key to the remote host's .ssh/authenticated_keys, this should work:
I have just tested after running
coder gitssh
:Added the key to the remote .ssh/authenticated_keys
Then