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

Better Ansible compatibility #929

Closed
kontsevoy opened this issue Apr 13, 2017 · 4 comments · Fixed by #1064
Closed

Better Ansible compatibility #929

kontsevoy opened this issue Apr 13, 2017 · 4 comments · Fixed by #1064
Assignees

Comments

@kontsevoy
Copy link
Contributor

Currently, if you want to use Ansible with Teleport, you have to configure OpenSSH client ssh to use Teleport auth via an agent. This is not hard, but introduces extra moving parts.

A much cooler way to do this would be to have tsh behave exactly like ssh. So imagine you have a symlink:

/usr/bin/tsh -> /usr/bin/ssh

Now, when you execute /usr/bin/ssh you're actually executing tsh and tsh by looking at it's arg[0] can see ssh in there and assume tsh ssh was given. This would make Ansible work natively via tsh without having the agents run around.

Assigning for myself as a small weekend project.

@kontsevoy kontsevoy self-assigned this Apr 13, 2017
@nikatjef
Copy link
Contributor

I know this is really basic code, but this appears to work for me;

/*
Copyright 2017 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
	"github.com/gravitational/teleport/tool/tsh/common"
)

import (
	"os"
	"path"
)

func main() {
	cmd_line_orig := os.Args[1:]
	cmd_line := []string{}
	switch path.Base(os.Args[0]) {
		case "ssh":
			cmd_line = append([]string{"ssh"}, cmd_line_orig...)
		case "scp":
			cmd_line = append([]string{"scp"}, cmd_line_orig...)
		default:
			cmd_line = cmd_line_orig
	}
	common.Run(cmd_line, false)
}

I then created a symlink for ssh and scp;

ln -snf /usr/local/bin/tsh /usr/bin/ssh
ln -snf /usr/local/bin/tsh /usr/bin/scp

Ran a couple of very basic tests. All of them were successful.

@kontsevoy
Copy link
Contributor Author

@nikatjef woo! thanks, exactly what I was thinking about. And you tried this under ansible, correct?

@nikatjef
Copy link
Contributor

I don't use ansible, but I did test the commands as basic SSH and SCP commands, including using batch commands to SSH and a single recursive directory copy with SCP.

@ksorathiya
Copy link

so the only thing i need to do to make ansible work with teleport is this?

ln -snf /usr/local/bin/tsh /usr/bin/ssh
ln -snf /usr/local/bin/tsh /usr/bin/scp

if not, what else do i need to set ?

hatched pushed a commit to hatched/teleport-merge that referenced this issue Nov 30, 2022
* Fix menu bug that adds features unto existing features
* Add missing top spacing for OSS Account view
* Update e-ref
hatched pushed a commit that referenced this issue Dec 20, 2022
* Fix menu bug that adds features unto existing features
* Add missing top spacing for OSS Account view
* Update e-ref
hatched pushed a commit that referenced this issue Feb 1, 2023
* Fix menu bug that adds features unto existing features
* Add missing top spacing for OSS Account view
* Update e-ref
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants