SFTP is based upon SSH; hosts you connect to, just like with ssh, will provide you with a unique key which allows you to identify them. If you accept the key, any time in the future you connect to the same host the provided key will be checked against the one provided the first time (which is stored in $HOME/.ssh/known-hosts) and if the two match you will not be asked again; if instead the two keys do not match you will be warned of a possible attack (a Man In The Middle attack, MTIM).
So it is basically a security feature. SSH is based on TOFU (Trust On First Use). Which means you will have to accept the key after checking with the sysadmin that the presented key is indeed theirs, and then proceed to establish the communication.
EDIT:
How to check that we are being presented the right key, short of asking a (possibly non-existent) sysadmin? When you connect to a SSH/SFTP server for the first time, you are presented with something like the following:
$ ssh me@remote The authenticity of host '[remote]:22 ([192.168.1.72]:22)' can't be established. ECDSA key fingerprint is b2:2d:52:1a:40:c2:f9:ca:9a:42:86:76:f4:0b:eb:84. Are you sure you want to continue connecting (yes/no)?
Jot down the kind of fingerprint (ECDSA, above) and the fingerprint itself, b2:2d:52:1a:40:c2:f9:ca:9a:42:86:76:f4:0b:eb:84
above. Now go to the server(either physically or, in the case of a VPS, to the console), and, without any need to sudo su
, go to /etc/ssh. You will see that there are many .pub
files; one is ssh_host_ecdsa_key.pub (the type of fingerprint we were presented). Now issue this command:
$ ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub
Its output must match the fingerprint you were offered above. If it does, you may now accept the key fingerprint in the ssh session, and proceed to ssh into the server.
There is no need to import anything from the server: ssh will take care of this for you.