{"id":16990389,"url":"https://github.com/aliasadidev/ssh-scp","last_synced_at":"2026-04-10T16:49:03.839Z","repository":{"id":240851799,"uuid":"613998358","full_name":"aliasadidev/ssh-scp","owner":"aliasadidev","description":"Provides SCP functionality","archived":false,"fork":false,"pushed_at":"2023-03-14T20:42:22.000Z","size":66,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T05:56:30.894Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aliasadidev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-14T17:27:20.000Z","updated_at":"2023-03-20T15:31:17.000Z","dependencies_parsed_at":"2024-05-21T04:55:56.518Z","dependency_job_id":"b6354287-1e19-4f9e-80d9-466cadcdc11f","html_url":"https://github.com/aliasadidev/ssh-scp","commit_stats":null,"previous_names":["aliasadidev/ssh-scp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliasadidev%2Fssh-scp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliasadidev%2Fssh-scp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliasadidev%2Fssh-scp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliasadidev%2Fssh-scp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aliasadidev","download_url":"https://codeload.github.com/aliasadidev/ssh-scp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244900134,"owners_count":20528638,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T03:09:52.965Z","updated_at":"2026-04-10T16:48:58.783Z","avatar_url":"https://github.com/aliasadidev.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ssh-scp\nProvides SCP functionality\n# ######### NEED TO BE REFACTORED #########\n# features\n- **Download a file**\n- **Upload a file**\n- **Get list of dirs**\n- **Get list of files**\n- **Check a file is exist**\n\nFollow this project: [Sample-Project](https://github.com/aliasadidev/ssh-scp/tree/main/sample/SshScp.Sample)\n\n# appsettings\n```json\n{\n  \"SshSettings\": {\n    \"ServerUrl\": \"127.0.0.1\",\n    \"Port\": 22,\n    \"User\": \"ali\",\n    \"PrivateKeyPath\": \"./keys/id_rsa\",\n    \"MaxConnections\": 10,\n    \"ListCommand\": {\n      \"ls_only_dir\": {\n        \"win32\": \"Get-ChildItem {0} -Directory -Name\",\n        \"linux\": \"ls -l {0} | awk '/^d/{{print $9}}'\"\n      },\n      \"ls_only_file\": {\n        \"win32\": \"Get-ChildItem {0} -File -Name\",\n        \"linux\": \"ls -Ap {0} | egrep -v /$\"\n      },\n      \"file_exists\": {\n        \"win32\": \"Test-Path -Path {0} -PathType Leaf\",\n        \"linux\": \"[ -f {0} ] \u0026\u0026 echo True || echo False\"\n      }\n    }\n  }\n}\n```\n\n# Sample\n```cs\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Logging;\nusing Microsoft.Extensions.Configuration;\nusing Microsoft.DevTunnels.Ssh.Tcp;\nusing Microsoft.DevTunnels.Ssh;\nusing System.Diagnostics;\nusing SshScp.Sample.SSH;\nusing SshScp;\nusing SshScp.Sample;\n\nIConfiguration configuration = new ConfigurationBuilder()\n               .SetBasePath(Directory.GetCurrentDirectory())\n               .AddJsonFile(\"appsettings.json\", optional: true, reloadOnChange: true)\n               .Build();\n\n//setup DI\nvar serviceProvider = new ServiceCollection()\n    .AddSingleton\u003cSshClient\u003e(sp =\u003e new SshClient(SshSessionConfiguration.Default, new TraceSource(nameof(SshClient))))\n    .AddTransient\u003cICustomSshClientSession, CustomSshClientSession\u003e()\n    .AddTransient\u003cICustomSshClient, CustomSshClient\u003e()\n    .AddTransient\u003cISshService, SshService\u003e()\n    .AddTransient\u003cScpClient\u003e()\n    .Configure\u003cSshSettings\u003e(configuration.GetSection(\"SshSettings\"))\n    .BuildServiceProvider();\n\n\nusing var loggerFactory = LoggerFactory.Create(loggingBuilder =\u003e loggingBuilder.SetMinimumLevel(LogLevel.Debug).AddConsole());\n\nILogger logger = loggerFactory.CreateLogger\u003cProgram\u003e();\n\n\n\nvar sshService = serviceProvider.GetService\u003cISshService\u003e();\n\nvar files = await sshService.ListFilesInDirectory(\"/home/ali/github/ssh-scp/sample/SshScp.Sample\", OperatingSystems.linux);\nvar dirs = await sshService.ListDirectories(\"/home/ali/github/ssh-scp/\", OperatingSystems.linux);\n\nSystem.Console.WriteLine(\"------------------------- DIRs -----------------------\");\nforeach (var dir in dirs)\n{\n  System.Console.WriteLine(dir);\n}\n\nSystem.Console.WriteLine(\"------------------------- FILES -----------------------\");\n\nforeach (var file in files)\n{\n  System.Console.WriteLine(file);\n}\n\nSystem.Console.WriteLine(\"------------------------- Download a file -----------------------\");\n\nbyte[] byteArray = await sshService.DownloadFile(\"/home/ali/github/csharp-refactor/images/icon.png\", OperatingSystems.linux);\nFile.WriteAllBytes(\"icon.png\", byteArray);\n\nSystem.Console.WriteLine(\"------------------------- Upload a file -----------------------\");\n\nFileStream fileStream = new FileStream(\"/home/ali/github/csharp-refactor/images/icon.png\", FileMode.Open, FileAccess.Read);\nawait sshService.UploadFile(fileStream, \"new.png\", \"/home/ali/github/ssh-scp/\", OperatingSystems.linux);\n\n\n\n```\n# Result\n![overview.jpg](sample/SshScp.Sample/images/overview.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliasadidev%2Fssh-scp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faliasadidev%2Fssh-scp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliasadidev%2Fssh-scp/lists"}