aboutsummaryrefslogtreecommitdiff
path: root/ssh_client.go
AgeCommit message (Collapse)Author
2024-04-06all: comply with linter recommendationsShulhan
2024-03-22all: replace module "share" with "pakakeh.go"Shulhan
The "share" project has been moved to SourceHut with new name "pakakeh.go".
2023-12-22all: support cancellation when running command using SSH clientShulhan
This changes require us to replace golang.org/x/crypto with our fork, since the [ssh.Session.Run] with context is not available yet in upstream. Implements: https://todo.sr.ht/~shulhan/awwan/9
2023-12-19go.mod: update share moduleShulhan
This fix fetching SSH config where Hostname is not set but host name may match with Host with wildcard.
2023-12-17all: change the remote temporary directory to "~/.cache/awwan"Shulhan
If the file to be copied contains sensitive data, putting them in "/tmp" considered a security risk, even though it will be moved to destination later. The issue is when the "#put" command failed, the plain file is left on "/tmp" directory. This changes add additional advantage where we did not need to remove the temporary directory on remote when execution completed, since the temporary directory should be accessible by user only. Implements: https://todo.sr.ht/~shulhan/awwan/8
2023-12-14all: close the SSH connection once Play finishedShulhan
Previously, we used to run awwan as CLI so each connection is open and closed (forcefully). Since we now use awwan WUI frequently, any command that execute Play does not close the session immediately once finished. This cause many connections open in remote server. This changes close the SSH connections immediately once the Play command finished.
2023-12-14all: changes based on reports from linter reviveShulhan
Better to fix and follow the reported warnings rather than adding configuration file to add an exception.
2023-11-16all: refactoring, rename Request to ExecRequestShulhan
2023-10-30all: pass Request when creating new SSH clientShulhan
Instead of passing stdout and stderr as "io.Writer", pass the Request, so we can log using the Request mlog. While at it, return error from sshClient rmdirAll so the caller can log the error.
2023-10-21all: implement remote "#get!" and "#put!" with owner and modeShulhan
When script with magic command "#get!" or "#put!" executed using "play" command, one can changes the owner and/or permission mode by setting the user/group and permission bits after the magic command, for example, #get!user:group+0600 src dst Will changes the owner of dst in local into "user:group" with permission "0600", while #put!user:group+0600 src dst Will changes the owner of dst in remote into "user:group" with permission "0600".
2023-10-21all: implement remote "#get:" and "#put:" with owner and modeShulhan
In remote environment, using magic command "#get:" or "#put:" with owner and mode like "#get:$OWNER+$MODE" or "#put:$OWNER+MODE" will changes the file owner to $USER or $GROUP and/or permission to $MODE. The file owner will not works if user does not have permission.
2023-09-26all: add prefix "awwan." to the name of temporary directoryShulhan
Each time the new session is created in local or remote, it will create new temporary directory. Previously, the name of temporary directory is random 16 characters and numbers. To distinguish this directory with others, we add prefix "awwan." to the name.
2023-09-26all: move ssh and sftp client into separate structShulhan
The sshClient struct wrap the raw SSH connection and SFTP connection, and provide methods get, put, sudoGet, sudoPut, mkdir, and rmdirAll.