0

I am trying to write a little SwiftUI app that connects to my server so I can display files and visually use SFTP (kind of like FileZilla). I have a function called SSH that executes on a button press, here it is:

func ssh(user: String, domain: String, password: String) {
    let arg = "ssh " + user + "@" + domain
    let task = Process()
    task.launchPath = "/usr/bin/ssh"
    task.arguments = [arg]
    task.launch()
    task.waitUntilExit()
}

When I call the function, I get this nasty error message in the Xcode console:

2020-11-25 11:05:35.122998-0800 SFTP App[25287:1434441] Metal API Validation Enabled
2020-11-25 11:05:49.056839-0800 ssh[25291:1434628] [] nw_resolver_can_use_dns_xpc_block_invoke Sandbox does not allow access to com.apple.dnssd.service
2020-11-25 11:05:49.057250-0800 ssh[25291:1434628] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:4 Err:-1 Errno:1 Operation not permitted
2020-11-25 11:05:49.057351-0800 ssh[25291:1434628] [connection] nw_resolver_create_dns_service_locked [C1] DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563)
ssh: Could not resolve hostname connect.markregg.com: -65563

I am able to connect to my server using the following terminal command and then entering my password:

ssh mark@connect.markregg.com
Mark Reggiardo
  • 467
  • 2
  • 4
  • 15
  • Edited with new error message from code, btw I'm a beginner to Swift in case you couldn't tell :) – Mark Reggiardo Nov 25 '20 at 19:07
  • 1
    When `/usr/bin/ssh` is the binary of your SSH-Client, and your args are `"ssh " + user + "@" + domain`. Then your result is `/usr/bin/ssh ssh Joe@server.xyz`. Are you sure that this is correct? – JekO Nov 25 '20 at 19:13
  • Also have you disabled the sandbox? https://stackoverflow.com/questions/7018354/remove-sandboxing – Andrew Nov 26 '20 at 06:48

0 Answers0