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

Scp example requires -O flag with openssh 9.0 #40

Closed
neurosnap opened this issue Apr 17, 2022 · 7 comments · Fixed by #224
Closed

Scp example requires -O flag with openssh 9.0 #40

neurosnap opened this issue Apr 17, 2022 · 7 comments · Fixed by #224
Assignees
Labels
enhancement New feature or request

Comments

@neurosnap
Copy link

Greetings!

Love the library and everything you all are working towards!

openssh v9 just released which changes the default protocol for scp https://www.openssh.com/txt/release-9.0

The current scp example does not work unless specifying the -O flag.

It seems like anyone that wishes to implement an scp server now needs to support both: legacy scp and sftp.

I wanted to surface that potential issue here as well as ask a general question about implementation.

I'm probably going to start working on adding sftp support to scp but wondered if you all had any advice on how to best implement it? Happy to send whatever I come up with upstream.

Thanks!

@caarlos0
Copy link
Member

definitely something to look into, thanks for reporting!

@caarlos0 caarlos0 self-assigned this Apr 21, 2022
@caarlos0 caarlos0 added the enhancement New feature or request label Apr 21, 2022
@caarlos0
Copy link
Member

caarlos0 commented Jul 6, 2022

something to look at: https:/pkg/sftp

@neurosnap
Copy link
Author

Happy to submit a PR, it's still a WIP, but we have a working version at pico.sh:

https://git.sr.ht/~erock/wish/tree/main/item/send/send.go#L11

@caarlos0
Copy link
Member

caarlos0 commented Jul 6, 2022

ah, amazing @neurosnap , would be neat! Don't need to worry too much, I can finish what you started :)

thanks!

@dezren39
Copy link
Contributor

found a 2024 url for picosh/send sftp: https:/picosh/send/blob/41432db245e0a519290e1e38442dc16cbc0fe802/send/sftp/sftp.go#L50

@caarlos0
Copy link
Member

caarlos0 commented Jan 16, 2024

while I can't repro the original issue here, if you need sftp, you can do something like:

	s, err := wish.NewServer(
		wish.WithAddress(fmt.Sprintf("%s:%d", host, port)),
		wish.WithHostKeyPath(".ssh/term_info_ed25519"),
		func(s *ssh.Server) error {
			s.SubsystemHandlers = map[string]ssh.SubsystemHandler{
				"sftp": func(s ssh.Session) {
					log.Info("using sftp")
					srv, err := sftp.NewServer(s, sftp.WithServerWorkingDirectory("/tmp/dir"))
					if err != nil {
						wish.Fatalln(s, err)
					}
					if err := srv.Serve(); err == io.EOF {
						if err := srv.Close(); err != nil {
							wish.Fatalln(s, err)
						}
					} else if err != nil {
						wish.Fatalln(s, err)
					}
				},
			}
			return nil
		},
		wish.WithMiddleware(
			scp.Middleware(handler, handler),
		),
	)

caarlos0 added a commit that referenced this issue Jan 16, 2024
This would allow users to more easily provide both SCP and SFTP servers
to their users.

closes #40

Signed-off-by: Carlos Alexandro Becker <[email protected]>
@caarlos0
Copy link
Member

also #224 should make it easier to do so:

https:/charmbracelet/wish/pull/224/files#diff-0e073cd2eec6b81539c170b0ce89175003229e8833999c3d39bb763cc668ba96

caarlos0 added a commit that referenced this issue Jan 22, 2024
* feat: better integration with pkg/sftp

This would allow users to more easily provide both SCP and SFTP servers
to their users.

closes #40

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* test: fix

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* test: add tests

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* feat: sftp refactory

* fix: aymans suggestions

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: aymans suggestions

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: make sftp an example instead

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* chore: update docs

* fix: tests

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: unexport

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: unexport

Signed-off-by: Carlos Alexandro Becker <[email protected]>

---------

Signed-off-by: Carlos Alexandro Becker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants