SFTP Server
SFTP Server
sftp-server is an in-memory SFTP Server implementation written in Go that can be used in Go unit-tests to test code that interacts with an SFTP server.
Explore the docs »
Report Bug/Issue
·
Request Feature
Table of Contents
-
About The Project
-
Getting Started
- Usage
- Roadmap
- Contributing
- License
- Contact
About The Project
sftp-server is an in-memory SFTP Server implementation written in Go that can be used in Go unit-tests to test code that interacts with an SFTP server. It is useful for ensuring that your code works correctly with an SFTP server without having to run an SFTP along with your tests or to have to mock the SFTP server which can be a complex task to do.
Built With
Getting Started
Usage
server := sftpserver.New("localhost:2022", "sculley", "password")
if err := server.Start(); err != nil {
log.Fatal("Failed to start test SFTP server:", err)
}
defer server.Stop()
conn, err := ssh.Dial("tcp", "localhost:2022", &ssh.ClientConfig{
User: "sculley",
Auth: []ssh.AuthMethod{
ssh.Password("password"),
},
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
})
if err != nil {
log.Fatal("Failed to dial SFTP server:", err)
}
client, err := sftp.NewClient(conn)
if err != nil {
log.Fatal("Failed to create SFTP client:", err)
}
files, err := client.ReadDir("/tmp")
if err != nil {
log.Fatal("Failed to list files: ", err)
}
for _, file := range files {
log.Println(file.Name())
}
Issues
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!
- Clone or Fork the project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request to merge into develop
License
Distributed under the Apache License. See LICENSE.txt
for more information.
Contact
Project Link: https://github.com/sculley/sftp-server