Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using secure copy to import IOS #16

Open
jcarte20 opened this issue Apr 6, 2021 · 3 comments
Open

Using secure copy to import IOS #16

jcarte20 opened this issue Apr 6, 2021 · 3 comments

Comments

@jcarte20
Copy link

jcarte20 commented Apr 6, 2021

I am a student at ASU and I am working on my capstone project.
I am trying to write a python program that will update the the Cisco IOS via netmiko.
I do have ip scp server enabled on my 2960 Cisco Switch.
When I run the program I get the following error code:

File "C:\Users\stscs\AppData\Local\Programs\Python\Python38\lib\site-packages\netmiko\scp_handler.py", line 360, in transfer_file
self.put_file()
File "C:\Users\stscs\AppData\Local\Programs\Python\Python38\lib\site-packages\netmiko\scp_handler.py", line 373, in put_file
self.scp_conn.scp_transfer_file(self.source_file, destination)
File "C:\Users\stscs\AppData\Local\Programs\Python\Python38\lib\site-packages\netmiko\scp_handler.py", line 46, in scp_transfer_file
self.scp_client.put(source_file, dest_file)
File "C:\Users\stscs\AppData\Local\Programs\Python\Python38\lib\site-packages\scp.py", line 158, in put
self._recv_confirm()
File "C:\Users\stscs\AppData\Local\Programs\Python\Python38\lib\site-packages\scp.py", line 363, in _recv_confirm
raise SCPException(asunicode(msg[1:]))
scp.SCPException: Privilege denied.

@ktbyers
Copy link
Owner

ktbyers commented Apr 6, 2021

You need privilege level 15 access on the account you are using to SCP (direct i.e. you can't require an enable call since there is no way to do this on the Secure Copy channel).

@jcarte20
Copy link
Author

jcarte20 commented Apr 6, 2021

Makes sense: so I wrote the following code into my function to hopefully configure SCP:
ssh = ConnectHandler(**conn)
ssh.enable()
ssh.send_command('aaa authentication login default local')
ssh.send_command('username easypair privilege 15 password cisco')
ssh.send_command('ip scp server enable')

@jcarte20
Copy link
Author

jcarte20 commented Apr 6, 2021

remaining code to import IOS:

transfers IOS to Cisco device and will overwrite the current IOS

    file_transfer(ssh, 
    source_file = IOS, 
    dest_file = IOS, 
    file_system = 'flash:', 
    direction = 'put', 
    disable_md5= True,
    overwrite_file = False,)
    ssh.disconnect()
    messagebox.showinfo('Info', 'Process is Complete')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants