Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

initial import

  • Loading branch information...
commit b32642bf4aa56e2a0c71f1ede2e35e05f8dc357c 0 parents
Jason Draper authored
Showing with 46 additions and 0 deletions.
  1. +28 −0 local.rb
  2. +18 −0 remote.rb
28 local.rb
@@ -0,0 +1,28 @@
+username = ARGV[0]
+server = ARGV[1]
+ssh_key = File.expand_path("~/.ssh/")
+ssh_key_file_name = ""
+remote_file_name = "remote.rb"
+#check for local ssh key and setup if necessary
+unless File.exist?(ssh_key)
+ #need to prompt the user to create the key
+ puts "You have not setup your public and private keys. You will now do that. After you have done that we will complete the process"
+ `ssh-keygen -t rsa`
+#upload the ssh key
+puts "Uploading the ssh key to remote server"
+system "scp #{ssh_key} #{username}@#{server}:#{ssh_key_file_name}"
+#upload the remote file to the server
+puts "Uploading the ruby script to the remote server"
+system "scp remote.rb #{username}@#{server}:#{remote_file_name}"
+#execute the script on the remote server
+puts "Executing the script on the server"
+system "ssh #{username}@#{server} 'ruby remote.rb'"
+#clean up the script
+puts "Cleaning up the files on the server"
+system "ssh #{username}@#{server} 'rm -rf; rm -rf remote.rb'"
18 remote.rb
@@ -0,0 +1,18 @@
+authorized_keys_file = File.expand_path("~/.ssh/authorized_keys")
+#check to see if there is an authorized_keys
+unless File.exists?(authorized_keys_file)
+ #create the authorized_keys file
+ unless File.exists?(File.expand_path("~/.ssh/"))
+ #create the .ssh directory
+ system "mkdir .ssh"
+ end
+ system "touch .ssh/authorized_keys"
+#cat the to the end of the authorized keys
+system "cat >> .ssh/authorized_keys"

0 comments on commit b32642b

Please sign in to comment.
Something went wrong with that request. Please try again.