问题原文
原帖链接 · Jack Avante · CC BY-SA 4.0
I'm quite new to this, and I've looked through questions but haven't found one that quite matches my problem, or rather I didn't sufficiently understand them to be able to solve this issue.
I have a new server to which I can only access using a pre-generated SSH RSA key pair, which allows me to connect only to the default ubuntu user
ssh -i .ssh/mykey ubuntu@ipaddr
On the server I created a new user, newuser, and I'm trying to make it, so I can use my key that I connect to ubuntu on that account as well, but I'm not sure how to accomplish this, so I can then delete the ubuntu user.
ssh-copy-id -i .ssh/mykey.pub -o "IdentityFile .ssh/mykey" newuser@ipaddr
That though returns permission denied. How can I do this effectively? Any password login is disabled and can't be enabled in this instance.
已采纳解答
原帖链接 · Gerald Schneider · CC BY-SA 4.0
- ssh to your old user
ubuntu - use
sudo -i -u newuserto switch to the new user - open
~newuser/.ssh/authorized_keyswith your favourite editor and copy&paste the content of your new public key into it - set proper permissions on the
.sshdirectory and the files inside it.
you may need to create the directory ~newuser/.ssh if it doesn't exist yet
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
