title: SSH connectivity using Swift
body: <p>Recently, I've been trying to make a (very) simple program with Swift that lets you connect to a server through SSH and execute some files. Unfortunately, I could not figure out how to start an SSH session completely within the Swift app. Here is some code that I have written:</p>
  
  <pre><code>var sshConnectCommand = ["-c", "spawn ssh "+sshUsername+"@"+sshHost+"; expect assword:; send "+sshPassword+"\r"]
  func sshIn() {
      //starting ssh session
      let sshConnect = NSTask()
      sshConnect.arguments = [testCmd]
  
      //rerouting output through a pipe
      sshConnect.standardOutput = logAppend
  
      //launch!
      sshConnect.launch();
  }
  </code></pre>
  
  <p>As you can see, I have used NSTask to try and run the 'expect' command to enter the password and everything. I would like to try and avoid using SSH-keygen as much as possible as this is intended to be used a server that the user does not have any access to.</p>
  
  <p>So, to sum up:
  How would you connect to SSH without SSH-keygen while remaining completely within the application code?</p>
  
  <p>edit: I should also add, when trying to compile, I get this error:
  <code>[Swift._SwiftDeferredNSArray fileSystemRepresentation]: unrecognized selector sent to instance 0x600000032500</code>. I'm not sure what this means.</p>