aboutsummaryrefslogtreecommitdiff
path: root/lib/ssh/sftp/sftp_test.go
AgeCommit message (Collapse)Author
2026-01-15all: convert license and copyright to use SPDX identifiersShulhan
With help of spdxconv tool [1], we able to bulk update all files license and copyright format to comply with SPDX formats. [1] https://kilabit.info/project/spdxconv/
2024-03-09lib: move package "ssh/config" to "lib/sshconfig"Shulhan
Previously the "ssh/config" is used by the parent package "ssh" and "ssh/sftp" which is break the rule of package layer (the top package should be imported by sub package, not the other way around).
2024-03-05all: comply with linter recommendations #2Shulhan
HTTP request now implicitly create request with context. Any false positive related to not closing HTTP response body has been annotated with "nolint:bodyclose". In the example code, use consistent "// Output:" comment format, by prefixing with single space. Any comment on code now also prefixing with single space. An error returned without variables now use [errors.New] instead of [fmt.Errorf]. Any error returned using [fmt.Errorf] now wrapped using "%w" instead of "%s". Also, replace error checking using [errors.Is] or [errors.As], instead of using equal/not-equal operator. Any statement like "x = x OP y" now replaced with "x OP= y". Also, swap statement is simplified using "x, y = y, x". Any switch statement with single case now replaced with if-condition. Any call to defer on function or program that call [os.Exit], now replaced by calling the deferred function directly. Any if-else condition now replaced with switch statement, if possible.
2024-03-02all: move the repository to "git.sr.ht/~shulhan/pakakeh.go"Shulhan
There are several reasons that why we move from github.com. First, related to the name of package. We accidentally name the package with "share" a common word in English that does not reflect the content of repository. By moving to other repository, we can rename it to better and unique name, in this "pakakeh.go". Pakakeh is Minang word for tools, and ".go" suffix indicate that the repository related to Go programming language. Second, supporting open source. The new repository is hosted under sourcehut.org, the founder is known to support open source, and all their services are licensed under AGPL, unlike GitHub that are closed sources. Third, regarding GitHub CoPilot. The GitHub Terms of Service [1], allow any public content that are hosted there granted them to parse the content. On one side, GitHub helps and flourish the open source, but on another side have an issues regarding scraping the copyleft license [2]. [1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us [2]: https://githubcopilotinvestigation.com
2023-09-24ssh/sftp: add method to close client connectionShulhan
The Close method close the client sftp session and release all its resources.
2023-07-26lib/ssh: refactoring NewClientFromConfig, renamed to NewClientInteractiveShulhan
Previously, the NewClientInteractive blindly use the signers from Section.Signers. If one of the IdentityFile valid, it will add all the keys in IdentityFile to SSH agent. In this changes we try each IdentityFile independently. If the key is valid, client connected to remote machine, then only that key will be added to SSH agent. While at it we also rename the method to NewClientInteractive to indicate that the function will prompt for passphrase if one of the IdentityFile is encrypted.
2023-07-26ssh/config: refactoring, simplify the Section fieldsShulhan
Instead of storing each Section value in separate field, store them inside a map, Field. This reduce the size of Section and simplify adding or getting the key that we are not supported but maybe usable by user in the future. This changes introduce several new methods as replacement of field: * CASignatureAlgorithms: a method that return list of signature algorithms that Section set or the default * CanonicalDomains: a method that return CanonicalDomains set in Section * CanonicalizePermittedCNames: return the permitted CNAMEs set in Section, from KeyCanonicalizePermittedCNames. * CertificateFile: return list of certificate file * Environments: return system and/or custom environment that will be passed to remote machine. The key and value is derived from "SendEnv" and "SetEnv". * FieldBool: return field value as boolean * FieldInt: return the field value as int * Hostname: return the Hostname in this Section * IdentityAgent: return the path to SSH agent socket to be used * Port: return the remote machine port * User: return the remote user name * Set: set the Field using key and value
2021-07-12ssh/sftp: provide better error handlingShulhan
This changes check and return an error if * the server does not support sftp subsystem as ErrSubsystem * the client does not support the server version as ErrVersion Some response status code from server actually can be mapped to predefined errors from standar package, in this case * io.EOF for SSH_FX_EOF (status code 1) * fs.ErrNotExist for SSH_FX_NO_SUCH_FILE (status code 2) * fs.ErrPermission for SSH_FX_PERMISSION_DENIED Other errors are handled by wrapping ErrXxx variable withresponse message.
2021-07-12ssh/sftp: new package that implement SSH File Transport Protocol v3Shulhan
The sftp package extend the golang.org/x/crypto/ssh package by implementing "sftp" subsystem using the ssh.Client connection.