728x90
반응형
서론
dreamhack christmas ctf 문제를 만들고 upload를 하다가 생긴 문제를 해결하고 남겨둔다.
기본적으로 아래 링크를 따라 하면 되지만, 추가로 필요한 내용들이 다소 있는 듯...
Dreamhack Wiki
git을 이용한 파일 업로드를 위해서는 기본적인 Git 사용법의 숙지가 필요합니다. SSH 공개키 등록하기 생성된 문제를 Git으로 접근하려면 먼저 SSH 키를 서버에 등록해야 합니다. SSH 키를 생성한 적
dreamhack.io
ssh 공개키 등록하기.
위키에서 설명한 것과 같이 public키를 등록하면 된다.
그런데 잘 등록 하였음에도 불구하고 아래와 같이 에러 메시지가 나왔다.
┌[WyV3rN]-(hack/prob)-
└> ssh -T git@git.dreamhack.io
git@git.dreamhack.io: Permission denied (publickey).
이 경우 직접 개인키를 매칭해주면 등록 여부를 확인할 수 있다.
┌[WyV3rN]-(hack/prob)-
└> ssh -i ~/.ssh/id_rsa -T git@git.dreamhack.io
Welcome to DreamHack, @b1123455-2123-1234-1234-123423434234!
Repository clone하기.
이건 요약하자면 git의 폴더와 내 컴퓨터를 동기화 해준다고 생각하면 될 듯.
다만, rsa key가 등록되었음에도 불구하고 repository clone이 되지 않는 경우가 있다.
┌[WyV3rN]-(hack/prob)-
└> git clone git@git.dreamhack.io:테스트.git
Cloning into '테스트'...
git@git.dreamhack.io: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
위와 마찬가지로 ssh 키를 인식하지 못해 발생하는 문제이다.
이런 경우에는 ssh에 키를 추가해주면 된다.
┌[WyV3rN]-(hack/prob)-
└> eval `ssh-agent -s`
Agent pid 148
┌[WyV3rN]-(hack/prob)-
└> ssh-add ~/.ssh/id_rsa
Identity added: /home/wyv3rn/.ssh/id_rsa (wyv3rn@DESKTOP-ASDF123)
그럼 아래와 같이 잘 된다.
┌[WyV3rN]-(hack/prob)-
└> git clone git@git.dreamhack.io:테스트.git
Cloning into '테스트'...
remote: Counting objects: 29, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 29 (delta 9), reused 0 (delta 0)
Receiving objects: 100% (29/29), 9.38 KiB | 417.00 KiB/s, done.
Resolving deltas: 100% (9/9), done.
git에 파일 upload하기.
clone한 폴더 내에서 upload할 파일들을 잘 셋팅한 다음, 아래와 같은 명령어로 로컬 파일을 git에 upload 할 수 있다.
$ git tag //태그 list 확인.
$ git tag v1 // 현재 상태를 태그명 v1로 태그 생성
$ git push origin v1 // 태그명 v1을 git에 upload
$ git push --tags // 모든 태그를 upload
$ git tag -d v1 //로컬에서 태그명 v1을 삭제.
$ git push origin :tags/v1 //git의 태그명 v1을 삭제.
($ git push --delete origin v1 //위와 동일함.)
Tag 별로 다운로드 받기.
위와 같이 그냥 clone만하면 master tag의 데이터를 가져온다.
┌[WyV3rN]-(prob/테스트)-[git:master]-
└> ls
Description.md Specfile public
┌[WyV3rN]-(prob/테스트)-[git:master]-
└> cat Specfile
[wargame]
title =
tags = misc
flag =
만일 tag별로 파일을 push해 두었다면 아래와 같이 원하는 tag로 동기화(다운로드) 가능하다.
(이걸 몰라서... 몇번이나 전부다 지우고 다시 등록했는지...)
┌[WyV3rN]-(prob/테스트)-[git:master]-
└> git checkout v3
Note: switching to 'v3'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 8c1a1fd v2
┌[WyV3rN]-(prob/테스트)-[git:v3]-
└> ls
Description.md Dockerfile Specfile private public
728x90
반응형
'Tips & theory' 카테고리의 다른 글
command injection (2) | 2023.01.25 |
---|---|
libc database. local에서 사용해보자. (0) | 2023.01.07 |
C random 함수를 python에서 실행하기. (0) | 2022.12.09 |
for "민규" (0) | 2022.11.27 |
docker gdb attach & pid로 gdb attach (0) | 2022.11.25 |