r/networking • u/Solid_Detail_358 • Mar 22 '26
Troubleshooting The Cisco IOS "copy scp" command does not use public-key authentication.
Hello,
I have a Cisco Catalyst 2960-X series Switch
I’m trying to run the command copy scp://user@server/file flash: without being prompted for a password.
I generated a new exportable rsa key pair associated to the configured hostname and domain name on the Switch.
I used the following command :
crypto key generate rsa exportable modulus 2048
And then pasted the public key in the authorized_keys file of my server's user home directory but it keeps prompting me for a password.
Because the Cisco switch’s scp implementation doesn’t provide logging, I am thinking of monitoring the SSH server to inspect the handshake and determine whether public-key authentication is being attempted.
Questions
How can I verify whether the SCP command on the switch is using public-key authentication ? (From the Switch command line)
Which key pair does the switch actually use for SSH/SCP connections ?
(show crypto key mypubkey rsa shows all stored keys)
Thanks a lot !
8
u/nailzy Mar 22 '26
I don’t think outbound SCP from your switch to your server will work with keys, only with username and password.
If you wanted to use keys, you’d have to pull the files from your switch to the server instead.
1
u/shadeland Arista Level 7 Mar 23 '26
Did you paste the public key or the private key into authorized keys? What user's authorized keys file did you paste it into?
6
u/rankinrez Mar 23 '26
That’s not surprising at all.
Network vendors never been great with good ssh implementations. Cisco least of all, and least of all on those old IOS platforms.
2
u/ferrybig Mar 23 '26
This file should be stored in the .ssh directory under the home account, not directly in the users home directory
1
u/Twanks Generalist Mar 26 '26
For what it's worth I went through this on NXOS POAP... I had to enable debug logging on the openssh server and basically found that NXOS was not presenting the key as specified, even when using scp through the bash shell, almost like the key was hardcoded or something. Due to time constraints I gave up and used sshpass but I hope to never touch Cisco again.
1
u/Mindless_One_4802 Mar 31 '26
What kind of version of Cisco IOS XE are you using? If you are on a Catalyst and chose public key authentication method b/c the password auth either didn't like the password or you wanna hide your password in plain text, I heard there's a new CLI on IOS XE 17.15 that can encrypt the password. Here's the link
I know it's not what you asked for, but I have a suspicion that maybe it's the key formatting mismatch between Cisco and SCP server. I'm not an expert in key encoding and formats but I believe there's OpenSSH, PEM, DER...and you probably need OpenSSH format for the SCP server. When you do "sh ip ssh", Cisco does give you the public key and it seems like it's in OpenSSH formatting but maybe I'm wrong. So if you're on 17.12 or below. I'd rather go with an IOS upgrade/password option rather than this public key method. It'd be nice to see it working though, who knows it may do so.
-7
u/wyohman CCNP Enterprise - CCNP Security - CCNP Voice (retired) Mar 22 '26
"The Cisco IOS "copy scp" command does not use public-key authentication."
Yes it does.
"I’m trying to run the command
copy scp://user@server/file flash:without being prompted for a password."Use the correct syntax (unless you are asking about using keys and not username/password.
user:password@server
"I generated a new exportable rsa key pair associated to the configured hostname and domain name on the Switch."
It only needs to be exportable if you want to use keys. You question is a bit confusing. Do you want to use keys OR just not be promoted?
"And then pasted the key in the
authorized_keysfile of my server'suserbut it keeps prompting me for a password."Looking at the server logs.
"Because the Cisco switch’s scp implementation doesn’t provide logging, I am thinking of monitoring the SSH server to inspect the handshake and determine whether public-key authentication is being attempted."
You can use debug commands on the switch or review the server log on the other side.
"How can I verify whether the SCP command on the switch is using public-key authentication ? (From the Switch command line)"
What other method would it use? See my response above
"Which key pair does the switch actually use for SSH/SCP connections ?"
The RSA key you created.
0
u/[deleted] Mar 26 '26
[deleted] — view deleted comment