Skip to content

Bandit31->32

Level Goal

There is a git repository at ssh://bandit31-git@localhost/home/bandit31-git/repo via the port 2220. The password for the user bandit31-git is the same as for the user bandit31.

Clone the repository and find the password for the next level.

Commands useful to solve the level

Helpful Reading Material

Where to start?

When we cat the README.md file, we see that it gives us a set of instructions. We have to create a key.txt file and "push" it to our remote repository.

Part 1 : Stagging the key.txt file

We need to create a file called key.txt with the contents 'May I come in?'. The real challenge here will be to stage the key.txt file for commit.

Hint

Using the git-add man page and the Gitignore Documentation, can you figure out a way to stage the key.txt file?

Solution

When we run git add key.txt, we get the information that the key.txt file has been marked as ignored by git (you can cat the .gitignore file in order to understand why). Thus running the following command :

git add -f key.txt
we can tell git to add the key.txt file even if git has been told to ignore it.

Part 2 : Pushing the key.txt file to the repository

Now that we've added the key.txt file to the stagging area, we need to push the file to the repository to validate the challenge.

Hint

Using the git-commit and the git-push man pages, can you figure out how to push the file to the repository?

Solution

Each commit must have a, preferably explicit, commit message. Then after taking our snapshot of the state of the repository, we can then push our set of snapshots to the remote repository. We can use the -m option of git commit to specify the message on the command line.

Here are our two commands :

git commit -m "explicit commit message"
git push
As we followed all the instructions, we get the password for the next level in the response.

Full Solution
  1. echo "May I come in?" > key.txt to create the key.txt file.
  2. git add -f key.txt to forcefully add the key.txt file to the stagging area.
  3. git commit -m "explicit message" to commit the changes
  4. git push to push our changes to the remote repository

You can now jump to the next level