0

I'm using NMSSH in Swift in my app. I've successfully connected and able to execute commands. My question is fail to pass password when using scp and the password prompt. The relevant code is as below. Thanks all for answering.

var commands = ["scp filePath/filename username@xxx.xxx.xx.xx:~/testFromiPhone.txt","mypassword"]

func executeCommand() {
    let error: NSErrorPointer = nil
    for command in commands {
        sshQueue?.sync {
            var response: String?
            print("command: \(command)")
            response = self.session?.channel.execute(command, error: error, timeout: 10)
            print("response: \(response ?? "no response")")
        }
    }
}

What I'm trying to do is allow other users to SCP their file to my server. The session is connected to their client/server and username@xxx.xxx.xx.xx is mine. I hope to do the least change on their end.

Azure Leon
  • 11
  • 2
  • https://stackoverflow.com/a/43526842/13317 – Kenster Jul 10 '18 at 17:05
  • @Kenster Thanks for replying. In my case, this will execute on other user's client/server, so install another tool such as sshpass or expect is my last choice. My question is when I run the [PTY example](https://github.com/NMSSH/NMSSH/tree/master/Examples), I can write scp command and then input the password which I thought is also use "write command" in the package but it can't accept in my code? – Azure Leon Jul 10 '18 at 18:11

0 Answers0