require 'tempfile' class SSHServer def initialize(sshd_host, sshd_port, authorized_keys = nil) @sshd_host = sshd_host @sshd_port = sshd_port @authorized_keys = authorized_keys @pid = nil end def start @sshd_key_file = Tempfile.new("ssh_host_rsa_key", $config["TMPDIR"]) # 'hack' to prevent ssh-keygen from prompting to overwrite the file File.delete(@sshd_key_file.path) cmd_helper(['ssh-keygen', '-t', 'rsa', '-N', "", '-f', "#{@sshd_key_file.path}"]) @sshd_key_file.close sshd_config =< e if e.message == "No such process" return false else raise e end end assert_equal(1, ret, "This shouldn't happen") return true end end