I'm currently following a small game to get more familar with linux and security and got the following task:

The password for the next level is stored in /etc/bandit_pass/bandit14 and can only be read by user bandit14. For this level, you don’t get the next password, but you get a private SSH key that can be used to log into the next level. \ Note: localhost is a hostname that refers to the machine you are working on

For now I'm logged in with the user bandit13 in the machine where user bandit14 exists and got the private key. When executing the ssh -i command on the machine (as logged in user bandit13) I get access to the bandit14 profile:

ssh bandit14@server.org -i privatekeyfile

Now what bothers me is, can one log into your user account by just using the given SSH private key from any remote client? I tried to log in using my system but however, the server refused my key. I tried with PuTTY on windows and with the terminal on Mac OS X (with the same command). From what I know is, that the associated public key needs to be put into the authorized_keys file at the server (i.e. the machine that get's accessed). But why does logging in from the remote machine not work but from the local one?

Note: The public key is unknown, I got no access to the authorized_keys file on the server.

  • 3
    You can extract the SSH public key from a private key file by running ssh-keygen -yf privatekeyfile. – John Downey Aug 8 '14 at 12:19
  • @JohnDowney Thanks, I didn't know this one. – 0x8BADF00D Aug 8 '14 at 12:54
up vote 1 down vote accepted

Now as I understand this a game, certain liberties might have been take. I could be wrong is it possible that the game did the following:

  1. Installed the public key in authorized_keys
  2. The private key isn't encrypted, not requiring a password
  3. Restricted access by IP, so only local clients could connect.

Pretty contrived (it is a game after all), and no one would really do this... but it would fit the scenario.

  • They surely did install the public key in the authorized_keys file. The private key is indeed not requiring a password. However, this is not really a difference when connection remotely. The third one makes sense but is this even possible? May one restrict the usage of private key files by IP? Since I can connect with any user to the server remotely, the port is open. I don't know any other possibilities to do that. Anyways, thanks for answering, at least one did. :) – 0x8BADF00D Jul 26 '14 at 17:21
  • 1
    Seems possible, blog.tinned-software.net/… – RoraΖ Jul 27 '14 at 14:58

Hopefully you must have solved that task by now, if not then try :

ssh bandit14@localhost -i privatekey_file

  • This is not what I was asking. I wrote about connecting remotely, i.e. not from the local machine. – 0x8BADF00D Aug 8 '14 at 12:53

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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