-1

Hello and thanks for reading,

Basically, I'm taking over for someone on some system admin duties, learning as I go, but one problem I've run into is not having my public RSA key put onto a particular server--one that already has RSA-only access enabled.

So, basically, I can't SSH remotely into the server, but I do have physical access to the server in question and can log in directly, with superuser powers and everything. I need to get my own public key into the directory of authorized_keys on the server, or perhaps instead generate a new key from the command line and somehow send the new private key to my laptop.

I've tried copying my public key that is on other servers connected to this one already that I can remotely SSH into, but due to the RSA key restrictions, scp doesn't seem to want to be able to connect (permission denied: publickey).

Any ideas on how best to go about this? Not sure if something like loading the public key file to the server via USB is an option, either. Like I said, kind've a noob at Ubuntu.

Thanks much in advance.

Update: Firstly, thank you all for your contribution. I've got the file onto the server now, used a USB and figured out how to mount it to the server physically and copy the file over. Now the problem is when I try to cat the public key file into the .ssh/authorized_keys file, nothing happens--it reads out the SSH key, but the authorized_keys file remains blank.

The permissions should all be set properly according to tutorials--chmod 600, 700, 755, all that, but maybe I did it wrong. No error messages pop up.

  • I think you're overthinking this. Unless I'm misreading something you simply need to find a way to get a file onto this previously secured server, right? Stick your public key on a web server or ftp site and log in locally, then download it. – yoonix Aug 25 '14 at 23:06
  • See: ssh-import-id on Ubuntu. – MikeyB Aug 27 '14 at 17:55
0

This article in ubuntu's knowledge base tells you all of the steps required. https://help.ubuntu.com/community/SSH/OpenSSH/Keys

Here is the relevant information (I used this method myself on my company server, editing the file on my box):

(First, copy the file to a memory stick or to a location where you can download it once you are on the server - please read the comments below for other various methods provided by yoonix) - wget, curl, scp, ftp to a remote location where it is stored if you do not have a usb port. Another method is to email it to an account on the server.

After copying the file to the server:

The key you need to transfer to the host is in fact the public one. If you can log in to a computer over SSH using a password, you can transfer your RSA key by doing the following from your own computer:

Copy the public key file to the server and concatenate it onto the authorized_keys file manually. It is wise to back that up first:

cp authorized_keys authorized_keys_Backup

cat id_rsa.pub >> authorized_keys

You can make sure this worked by doing:

ssh <username>@<host>

You should be prompted for the passphrase for your key:

Enter passphrase for key '/home/<user>/.ssh/id_rsa':

Enter your passphrase, and provided host is configured to allow key-based logins, you should then be logged in as usual.

  • This doesn't answer the question asked. – yoonix Aug 25 '14 at 23:08
  • He said he has physical access to the box. The second method, editing the file EXACTLY answers the question asked. – Jeff Clayton Aug 25 '14 at 23:09
  • The server is set for key authentication only. How do you expect him to use ssh-copy-id without having a key on the server already? He can't since passwords are disabled. – yoonix Aug 25 '14 at 23:10
  • Please reread his statements, unless I misread it he stated he has physical control of the box as an admin, just not remotely. "but I do have physical access to the server in question and can log in directly" I gave multiple methods. To actually have the key to copy he would have to have it on a flash drive, etc... – Jeff Clayton Aug 25 '14 at 23:12
  • ... or he can just download the key while he's logged into the system in question. This is the public key, there's no need for a memory stick here. – yoonix Aug 25 '14 at 23:14
0

Thanks, everyone, for your answers, they were very helpful.

Ultimately my solution was to figure out how to mount a USB drive onto the physical server and copy over the public key file.

For whatever reason, doing the traditional concatenating of the file to the authorized_key folder wasn't working, even though I'm 99% sure I did the permissions properly, but I found out how to use Shift-Insert to just put the RSA key file info directly into authorized_keys, and it works like a charm now.

  • 2
    Between this and "Now the problem is when I try to cat the public key file into the .ssh/authorized_keys file, nothing happens--it reads out the SSH key, but the authorized_keys file remains blank", maybe you shouldn't have access to this server. – MikeyB Aug 27 '14 at 17:56
  • Too late, I've breached the server's RSA security, and with the nuclear launch codes I've obtained, I can now start WW3 remotely--all thanks to serverfault. – user3687873 Aug 27 '14 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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