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

Java Jsch library like sftp login interface implement #596

Open
je-ck opened this issue Sep 30, 2024 · 1 comment
Open

Java Jsch library like sftp login interface implement #596

je-ck opened this issue Sep 30, 2024 · 1 comment

Comments

@je-ck
Copy link

je-ck commented Sep 30, 2024

hi, is there a way to implement jsch sftp interface such as UserInfo, UIKeyboardInteractive to login sftp server?
I try to login with the following code:

	sshConfig := &ssh.ClientConfig{
		User: sftpUser,
		Auth: []ssh.AuthMethod{
			ssh.Password(sftpPassword),
			ssh.KeyboardInteractive(
				func(name, instruction string, questions []string, echos []bool) ([]string, error) {
					responses := make([]string, len(questions))
					for i, q := range questions {
						responses[i] = password
					}
					return responses, nil
				}),
		},
		HostKeyCallback: ssh.InsecureIgnoreHostKey(),
	}
	conn, err := ssh.Dial("tcp", addr, sshConfig)

but fail without setting up handshake and none prompt message, while jsch example login successfully with code like http://www.jcraft.com/jsch/examples/Sftp.java.html.
can you give me some example such as jsch or any advise to implement it?

@puellanivis
Copy link
Collaborator

From reading the ssh package documentation:

KeyboardInteractiveChallenge should print questions, optionally disabling echoing (e.g. for passwords), and return all the answers. Challenge may be called multiple times in a single session. After successful authentication, the server may send a challenge with no questions, for which the name and instruction messages should be printed. RFC 4256 section 3.3 details how the UI should behave for both CLI and GUI environments.

Said more directly, it’s not printing any prompts, because it’s the responsibility of the function you’re passing into KeyboardInteractive to print the prompt and collect the input.

I’m trying to provide the best help I can, but the ssh package is another package and maintained by different people. We might be able to help you from having some adjacent knowledge, but that package is really the place where such issues should be brought to get the best and most knowledgeable responses.

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