Score:0

Logged into remote server with key but can't upload file with scp

in flag

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 [email protected]

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?

hr flag
Just to be clear, are you trying to scp from your local (WSL) shell, or from the remote shell that you opened using ssh?
in flag
From the remote shell...I guess you're going to tell me that's why it's not working ;) ...in my defence, may I say that Google has been my only instructor here. Do I need to do it from my local shell?
hr flag
... yes you do, don't worry it's a common mistake
Score:0
in flag

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 servername

For scp it’s the same:

scp myfile.gz servername:/path/to/save

Alternatively, you can pass the key file to use with -i:

scp -i ~/.ssh/id_ed25519 myfile.gz [email protected]:/path/to/save
in flag
Thanks! - this morning I could log in with ssh servername, which I couldn't yesterday, so that's all good (if somewhat mysterious). Also, these all work:
in flag
... scp myfile.gz [email protected]:/path/to/save ....and... scp myfile.gz user@servername:/path/to/save (not that the extra verbiage is necessary, I was just curious)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.