Though Net::SCP makes heavy use of Net::SSH, it has an interface to use it without knowing how to use Net::SSH. This interface is best used if you only need to transfer files, not to run any commands or forward ports on the remote machine. If you already have an SSH connection open in your program, you should use the second method below.
Net::SCP is used in much the same way Net::SSH is. Simply call Net::SCP.start with the hostname, username and password, then use the upload and download methods to upload and download files.
Remember that when uploading or downloading files via SSH, the current working directory on the remote machine is always your home directory. Pathnames will either need to be relative to your home directory, or absolute paths. If you simply wish to upload a file to your home directory on the remote host, use a pathname of '.'.
hostname = 'host'
username = 'user'
password = 'pass'
Net::SCP.start( hostname, username, :password => password ) do|scp|
scp.upload!( 'scp1.rb', '.' )
scp.download!( 'test.txt', '.' )
As with the Net::SSH methods, the methods ending with the exclamation point will wait until the task finishes before returning.