ruby - Net::SSH sudo command hangs after entering password -
I am trying to write a small library from Thor to help in preparing new projects and sites quickly I am I've written a small method:
def ssh (cmd) net :: SSH.start (server_ip, user, port = & port; port) session. Session | Session.exec cmd end end
Please help me run quick commands on a remote server when needed
The problem is that when I am under pseudo If a command is required to run, then the script seems to be hanging for me, for example when it is executed ...
ssh ("sudo cp # {file_from_path} # {file_to_path} ")
script for me a password
[sudo] password for user:
but then completelyAfter typing it from hhangs
Know that this is hanging at all, and what can I do to run the sudo command on a remote server under Net :: SSH (or some optional)?
* Note: Prior to the suggestion, I had started writing basically until I came to Thor, by this library as a recipe under Capstrano, and thought it was There will be a good chance of trying out. I do not need to switch to Capistrano if back to the whole thing but I would just really be surprised if there is not an easy way to run sudo commands on a remote server.
The first thing you can try is to use a public key instead of a password to log in Still try to run commands from interactive shell. For example:
(This part actually depends on the server / client software)
$ ssh-keygen $ scp .ssh / id-dsa.pub Server: $ ssh server server $ cat id-dsa.pub & gt; & Gt; .ssh / authorizedkeys $ scp -c "ls"
This should work without any indication, if the main share was successful.
Comments
Post a Comment