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.
역시 마찬가지로 git repository를 clone하여 비밀번호를 찾는 것 같습니다.
이전 단계의 레벨과 동일하게 git clone까지 진행해 볼게요.
repo 폴더에 있는 README.md를 읽어봅시다!.
내용은 원격 저장소로 아래와 같은 내용의 파일을 푸시하라고 하네요!
bandit31@bandit:/tmp/bandit32_pass/repo$ cat README.md
This time your task is to push a file to the remote repository.
Details:
File name: key.txt
Content: 'May I come in?'
Branch: master
push라는 기능이 나왔군요.
이제 우리는 git에서 원격 저장소로 파일을 업로드하는 과정을 확실히 알아둘 필요가 있습니다.
📌 git에서의 업로드
1. add: 개인 로컬 컴퓨터에서 수정하거나 새로 만든 파일을 저장할 준비
- 마트에서 내가 필요한 물건들을 장바구니에 담는 단계라고 생각하면 됨
- git add milk.txt(우유를 장바구니에 담음)
2. commit: add를 통해 장바구니에 담은 물건을 구매(저장)하는 단계
- 커밋 메시지도 함께 받음
- git commit -m "우유 샀음"(실제로 저장함)
✅ 요약하자면 add는 수정한 파일을 커밋할 목록에 올리는 것이고 commit은 그 목록을 하나의 버전으로 기록하는 것
✅ commit까지는 git이 버전으로 기록하지만 아직 나만 보는 상태
3. push: 로컬에서 만든 커밋들을 원격 저장소에 업로드함
- 푸시를 해야 다른 사람과 공유할 수 있음
간략히 알아 봤으니 key.txt 파일을 push해 봅시다!
key.txt 파일을 먼저 생성하구요!
그 다음 add를 진행해야 겠죠?
bandit31@bandit:/tmp/bandit32_pass/repo$ echo 'May I come in?' > key.txt
bandit31@bandit:/tmp/bandit32_pass/repo$ cat key.txt
May I come in?
bandit31@bandit:/tmp/bandit32_pass/repo$ git add key.txt
The following paths are ignored by one of your .gitignore files:
key.txt
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
add를 하는 도중 오류가 나네요.
.gitignore에 의해서 key.txt 파일의 add가 안되는 것 같아요.
찾아보니 버전 관리를 하지 않은 파일을 지정해 놓는 것 같습니다.
숨김 파일로 된 .gitignore를 읽어보니 *.txt로 설정되어 있어 txt 파일은 add할 수 없나 봅니다.
근데 위를 보면 힌트가 있네요!
-f 옵션을 사용하면 무시하고 진행할 수 있나봅니다.
bandit31@bandit:/tmp/bandit32_pass/repo$ ls -a
. .. .git .gitignore key.txt README.md
bandit31@bandit:/tmp/bandit32_pass/repo$ cat .gitignore
*.txt
bandit31@bandit:/tmp/bandit32_pass/repo$ git add -f key.txt
오! add를 성공했구요.
이제 commit을 해야겠지요?
bandit31@bandit:/tmp/bandit32_pass/repo$ git commit -m "Upload key.txt"
[master b605923] Upload key.txt
1 file changed, 1 insertion(+)
create mode 100644 key.txt
메시지도 추가해서 commit 완료했습니다.
마지막으로 원격 저장소에 push를 진행해주면!!
짜잔! 비밀번호가 나오는군요 :)
bandit31@bandit:/tmp/bandit32_pass/repo$ git push origin master
The authenticity of host '[localhost]:2220 ([127.0.0.1]:2220)' can't be established.
ED25519 key fingerprint is SHA256:C2ihUBV7ihnV1wUXRb4RrEcLfXC5CXlhmAAM/urerLY.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Could not create directory '/home/bandit31/.ssh' (Permission denied).
Failed to add the host to the list of known hosts (/home/bandit31/.ssh/known_hosts).
_ _ _ _
| |__ __ _ _ __ __| (_) |_
| '_ \ / _` | '_ \ / _` | | __|
| |_) | (_| | | | | (_| | | |_
|_.__/ \__,_|_| |_|\__,_|_|\__|
This is an OverTheWire game server.
More information on http://www.overthewire.org/wargames
bandit31-git@localhost's password:
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 2 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 329 bytes | 329.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: ### Attempting to validate files... ####
remote:
remote: .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
remote:
remote: Well done! Here is the password for the next level:
remote: 3O9RfhqyAlVBEZpVb6LYStshZoqoSx5K
remote:
remote: .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
remote:
To ssh://localhost:2220/home/bandit31-git/repo
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://localhost:2220/home/bandit31-git/repo'
비밀번호: 3O9RfhqyAlVBEZpVb6LYStshZoqoSx5K