2

I was using scp and ssh suddenly some warning about

SOMETHING NAST!

man-in-the-middle attack

From that moment when that warning appeared till now, I can copy files via sftp but it is impossible to use scp. What's going on? I tried removing .ssh/known_hosts but it is always the same. When scp myfile user@server:/Folder, I get the following message.

scp: /Folder: Permission denied

Mario
  • 23

4 Answers4

3

Open the below file and erase the text within the file

vi /home/username/.ssh/known_hosts

restart again the scp command

hg8
  • 13,462
2

first, this is a security issue.

Here is a nice review article:

http://www.symantec.com/connect/articles/ssh-host-key-protection

Basically ssh servers (openssh-server) use keys to identify themselves and prevent others from mimicking them. A "man in the middle" might, for example, capture your user name and password.

You can fix it via several methods, I prefer

ssh-keygen -R server

Before you do that, however, you should check with the server sys admin to see if the (server) keys were changed.

For your scp error, you need to use the full path. My guess would be:

scp myfile user@server:/home/user_name/Folder
Panther
  • 102,067
  • I too had similar problem, But it works very well with ssh. I mean the same identity file works well with ssh, but scp throws this error. – indianwebdevil Apr 16 '16 at 05:39
  • This is not necessary a security issue, I fall on this I think because I have a VirtualBox VM that I redo from scratch, with same hostname then, and that probably made its identification change even if hostname did not. – gluttony Apr 21 '23 at 10:03
0

I fix by just open the file :- /home/username/.ssh/known_hosts and delete the line containing the server name and again ues the scp command. This generally happens when we use the commands in the different servers.

0

This will also happen if you have migrated a server onto another piece of hardware or changed IP Addresses. Generally, I copy the known_hosts file to a .bak; vi the file and remove the offending key. Then when I ssh in again, it prompts for the password and with permission adds it to the known hosts. You don't even have to put in a password, just say yes to known_hosts.

As stated previously though - SOMETHING changed so you need to find out what. These errors don't just magically appear so use caution!