View Single Post
Posts: 35 | Thanked: 20 times | Joined on Dec 2009
#228
Originally Posted by digitalvoid View Post
@ pigro & SaintGermain:

SMSCON uses the straight shell command interface for connecting with ssh.

Python ssh part in SMSCON:

Code:
(Output, ExitStatus) = pexpect.run( 'ssh -n -N -T -f -p %s -R %s:%s:%s %s@%s &' % (REMOTEPORT, LocalPort, LocalHost, REMOTEPORT, REMOTEUSER, REMOTEHOST), events = { '(?i)password':REMOTEPASSWORD + '\n', '(?i)(yes/no) ?':'yes' + '\n' }, withexitstatus = True )


SSH is started in background (in red) and when SSH ask for password it's automatically entered (green) and the connection has started if 'ExitStatus' returns 0). It's very basic done, I know, but It works.

If somebody has better code to implement in SMSCON please share it.
I just added "passphrase" to the regexp for making smscon compatible with 'public key authentication' (the password you provide in smscon_config will be processed as the passphrase to your private key):

Code:
(Output, ExitStatus) = pexpect.run( 'ssh -n -N -T -f -p %s -R %s:%s:%s %s@%s &' % (REMOTEPORT, LocalPort, LocalHost, REMOTEPORT, REMOTEUSER, REMOTEHOST), events = { '(?i)(password|passphrase)':REMOTEPASSWORD + '\n', '(?i)(yes/no) ?':'yes' + '\n' }, withexitstatus = True )
With that, I managed to make reverse-SSH works with public key authentication !

Here are some hints:
  1. smscon starts by checking the remote host status by pinging it: so check fist that you can also ping it (some GPRS provider are filtering 'ping' traffic). Maybe you can make it optional ?
  2. The private key to access your remote host has to be named id_rsa and have to put on your N900 in /root/.ssh directory with the proper rights (chmod 600 id_rsa). Maybe you can make it configurable ?
  3. The authorized keys to access your N900 has to be put in the file /root/.ssh/authorized_keys
  4. The remote host port and your N900 port has to be the same number (usually 22). Maybe you can split the REMOTEPORT in 2 ? REMOTEPORT and LOCALPORT ? Or better still, read the good local port number in /etc/ssh/sshd_config
  5. The openSSH server on your N900 has to be up and running. Maybe smscon can detect if the server is down and automatically start it ? I'm not sure about how to start openSSH if it has been deactivated at boot with /etc/ssh/sshd_not_to_be_run
  6. for debugging on your remote host if you are under linux, check /var/log/auth.log for authentication attempts/failures and use "netstat -taupe" to check current connections.

Other feedbacks in other post.
 

The Following 2 Users Say Thank You to SaintGermain For This Useful Post: