Secure Shell Access & Transfer with Ruby
SSH (Secure SHell) is a network protocol designed to be secure using various cryptographic technologies. It's very similar to telnet, but it is secure, so network a eavesdropper would be able to decipher your data that being transmitted over the network. In addition to being secure it has many features like data compression, reverse DNS checking, it can authenticate password-less using Private-Public key pairs.
In this article we'll see how to programatically SSH into servers, and run programs or other tasks. This can be useful in a variety of scenarios, like running an update on an array of servers, copying files to servers, fetching logs from servers at the end of the day and things the like that, use your imagination.
Installation of the gem is very easy, for demonstration purpose I'll install another module Net::SCP synonymous to the *nix command scp.
Issue the following commands on your shell prompt:
Now that we have understood what SSH is capable of, let us dive into some code examples to get to understand how to implement it, follow the examples below, I have added comments wherever necessary:
Now, let us look at copying files over to remote servers using SSH copy:
I hope you have enjoyed the article.
|All times are GMT +5.5. The time now is 22:56.|