-
Notifications
You must be signed in to change notification settings - Fork 471
Support subsystem #103
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
Closed
Closed
Support subsystem #103
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0cf6a78
Merge pull request #1 from gliderlabs/master
ibuler af264b1
[Update] 支持subsytem
ibuler 1ebc0d1
[Update] 添加example
ibuler 6e3e06f
[Update] Modify format for less modify
ibuler aeef898
[Bugfix] fix zmodem sz error
ibuler cab6d6e
fix panic bug when not found any subsystem
LeeEirc 6d985bd
Merge pull request #2 from LeeEirc/master
ibuler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/gliderlabs/ssh" | ||
"github.com/pkg/sftp" | ||
"io" | ||
"io/ioutil" | ||
"log" | ||
) | ||
|
||
func SftpHandler(sess ssh.Session) { | ||
debugStream := ioutil.Discard | ||
serverOptions := []sftp.ServerOption{ | ||
sftp.WithDebug(debugStream), | ||
} | ||
server, err := sftp.NewServer( | ||
sess, | ||
serverOptions..., | ||
) | ||
if err != nil { | ||
log.Printf("sftp server init error: %s\n", err) | ||
return | ||
} | ||
if err := server.Serve(); err == io.EOF { | ||
server.Close() | ||
fmt.Println("sftp client exited session.") | ||
} else if err != nil { | ||
fmt.Println("sftp server completed with error:", err) | ||
} | ||
|
||
} | ||
|
||
func main() { | ||
srv := ssh.Server{ | ||
Addr: ":2223", | ||
SubsystemHandlers: map[string]ssh.SubsystemHandler{}, | ||
} | ||
srv.SetSubsystemHandler("sftp", SftpHandler) | ||
log.Fatal(srv.ListenAndServe()) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If do that replace, zmodem sz will be error