SSH connectivity using Swift -


recently, i've been trying make (very) simple program swift lets connect server through ssh , execute files. unfortunately, not figure out how start ssh session within swift app. here code have written:

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 pipe     sshconnect.standardoutput = logappend      //launch!     sshconnect.launch(); } 

as can see, have used nstask try , run 'expect' command enter password , everything. try , avoid using ssh-keygen as possible intended used server user not have access to.

so, sum up: how connect ssh without ssh-keygen while remaining within application code?

edit: should add, when trying compile, error: [swift._swiftdeferrednsarray filesystemrepresentation]: unrecognized selector sent instance 0x600000032500. i'm not sure means.

i've been using similar ssh raspberry pi:

func sshin() {     let task = nstask()     task.launchpath = "/usr/bin/ssh"     task.arguments = ["username@ipaddress", "-t", "sudo systemctl stop mediacenter; /opt/vc/bin/tvservice -o"]     task.launch() } 

-t closes connection when commands finished running, , can pass in commands command1; command 2 i've got sudo systemctl stop mediacenter; /opt/vc/bin/tvservice -o keygen thing, don't think have of choice. can locking down bit though. here's place start looking.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -