Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was using scp and ssh suddenly some warning about


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

share|improve this question
up vote 1 down vote accepted

first, this is a security issue.

Here is a nice review article:

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
share|improve this answer
Thank you so much. – Mario Jan 12 '12 at 0:24
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. – nepsdotin Apr 16 at 5:39

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!

share|improve this answer

Open the below file and erase the text within the file

vi /home/username/.ssh/known_hosts

restart again the scp command

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.