Logged into remote server with key but can't upload file with scp
Matthew Martinez
New to Ubuntu, I logged into my institution's remote server having generated a private/public key pair. I was set up with a username after sending the administrator the public key. I should have been able to log in by using ssh myusername@servername but I can only log in if I replace the servername with the IP address, ssh
Now, wanting to upload a file I tried:
scp ~/myfile.rds myusername@servername:/home/myusername/...which got me a Permission denied (publickey). lost connection message. The administrator suggested trying again, replacing servername with the IP address. That makes sense, but still the same response.
My config file, saved at \\wsl$\Ubuntu\home\myUbuntuUsername\.ssh along with the two keys, reads:
Host servername HostName xxx.xx.x.xx Port 22 User myusername IdentityFile ~/.ssh/id_ed25519...where ~/.ssh/id_ed25519 is the path to the private key. What could I have got wrong?
1 Answer
Specifying the username in your ssh and scp commands shouldn’t be necessary, as the value is already in your ~/.ssh/config file. Instead, you can do this:
ssh servernameFor scp it’s the same:
scp myfile.gz servername:/path/to/saveAlternatively, you can pass the key file to use with -i:
scp -i ~/.ssh/id_ed25519 myfile.gz user@123.123.123.123:/path/to/save 2