Skip to content

Instantly share code, notes, and snippets.

@shutingrz
Created December 23, 2015 15:19
Show Gist options
  • Save shutingrz/81fcc11251a93564a3ed to your computer and use it in GitHub Desktop.
Save shutingrz/81fcc11251a93564a3ed to your computer and use it in GitHub Desktop.
require 'expect4r'
#gem install expect4r
@tftps = "" #tftpserver ipaddress or hostname
def bak_config(host,username,password, filename)
ios = Expect4r::Ios.new_telnet(
host: host,
user:username,
pwd: password,
enable_password: password
)
ios.login
ios.to_exec
puts ios.putline("copy startup-config tftp:\r" + @tftps + "\r" + filename , no_trim:true)
end
#bak_config("target_host","username","password","filename")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment