WSL 상에서 동작하는 Ubuntu 앱을 사용하면서 가장 불편한 점이 터미널이다. 윈도우에서 기본으로 제공하는 터미널을 사용해야 하기 때문에 폰트도 다르고 사용 편의성도 친숙하지 않는 것같다.


WSL 상에 동작하는 Ubuntu로 일반적으로 사용하는 터미널 프로그램(SecureCRT 나 putty 등)을 사용하여 ssh로 접속하는 방법을 찾아 보니 생각하던 그 방법대로 가능하다는 것을 알게 되었다.


1. install ssh

   % sudo apt install openssh-server


2. edit the sshd_config

   % sudo vi /etc/ssh/sshd_config

   change PasswordAuthentication to yes

   add AllowerUsers [ username ]


3. generate ssh key

   % sudo ssh-keygen -A


4. restart ssh service

   % sudo service ssh --full-restart


5. add Windows Firewall

   add inbound rules related to sshd


6. 참고자료

https://www.illuminiastudios.com/dev-diaries/ssh-on-windows-subsystem-for-linux/

https://gist.github.com/dentechy/de2be62b55cfd234681921d5a8b6be11

https://www.reddit.com/r/bashonubuntuonwindows/comments/5gh4c8/ssh_to_bash_on_wsl/


'컴맹의 컴퓨터 이야기 > 개발' 카테고리의 다른 글

[유틸] fisa vim config  (1) 2019.03.05
[팁] tortoiseSVN의 blame 기능  (0) 2014.08.25
[유틸] PowerMockup  (0) 2014.02.10
[팁] cygwin에서 mongo db 사용하기  (0) 2013.08.02
[팁] cygwin에서 libpcap 사용  (0) 2013.07.08

[유틸] fisa vim config

2019. 3. 5. 14:38 | Posted by 꿈꾸는코난

a vim configuration for the modern pythonista (plus some other goodies)


This is vim configuration, built according to personal preferences, without any justification to think it's the best possible vim configuration. It's mainly oriented to python software development, but many of its features are useful for other languages and editing tasks.



< Install >


0) You will need a vim compiled with python support. Check it with vim --version | grep +python


Also, your .vim folder should be empty. If you have one, rename it or move to a different location (to keep a backup, just in case you want to go back).


1) Install the required dependencies:

sudo apt-get install curl vim exuberant-ctags git ack-grep

sudo pip install pep8 flake8 pyflakes isort yapf


2) Download the .vimrc file and place it in your linux home folder.

( wget -O ~/.vimrc  https://raw.github.com/fisadev/fisa-vim-config/master/.vimrc )


3) Open vim and it will continue the installation by itself. Wait for it to finish... and done! You now have your new shiny powerful vim :)



< Most important features include: >


Plugins managed using Vim-plug! You can easily install or remove plugins, and they are installed into .vim/plugged/. More info here


Smart autocompletion as you type, sometimes using python instrospection (completion of module names, instance methods and attributes) and sometimes text-based (used words) (from version 4.0, it's even more intelligent!). And with neocomplcache, it even can autocomplete with typos, thanks to the fuzzy completion settings.


Fuzzy file, code and command finder (like Textmante or Sublime Text 2):


,e = open file (like the original :e) but with recursive and fuzzy file name matching. Example: if you type "mopy" it will find a file named "models.py" placed on a subdirectory. And allows you to open the selected file on a new tab with Ctrl-t!

,g = fuzzy symbol finder (classes, methods, variables, functions, ...) on the current file. Example: if you type "usr" it will find the User class definition on the current file. ,G does the same but on all opened files.

,c = fuzzy command finder (internal vim commands, or custom commands). Example: if you type "diff" it will find :GitDiff, :diffthis, and many other similar commands.

,f = fuzzy text finder on all the opened files. Example: if you type "ctm=6" it will find the line containing "current_time = 16".

,m = fuzzy finder of most recently used files.

,we, ,wg, ,wc, ,wf and ,wm = same as ,e, ,g, ,c, ,f and ,wm but initiate the search with the word under the cursor (also the upper case version of ,G, ,wG). Is useful to think about the ,wg as a "fuzzy go to definition" (if the definition is in the same file, or ,wG if the definition is on any of the opened files).

,pe = same as ,e but initiates the search with the path under the cursor.

Ropevim for really neat python goodies!:


Go to definition with ,d, or open the definition on a new tab with ,D.

Find occurrences with ,o.

Classes/module browser that lists classes, functions, methods, and such of the current file, and navigates to them when ENTER is pressed. Toggle it with F4.


Pending tasks browser pressing F2. This reads the current file searching for comments that start with "TODO", "FIXME", and such, and shows them on a list that allows navigation similar to the class browser.


Error checking of code using Syntastic (it will detect unused variables or imports, syntax errors, and such), for several languages, highlighting the errors and warnings in the code. You can open an errors list with \e. In python, the error checking includes pep8 validation, and pylint.


Grep code recursively and navigate the results:


,r uses the ack command (a kind of grep optimized for code search), lists the found matches, and allows you to open them with ENTER.

,wr does the same, but searching the word under the cursor.

Some settings for better tabs and spaces handling.


Better file browser, toggle it with F3, or open it with your current file selected using ,t.


Results count while searching text.


Search and read python documentation with the :Pydoc command. Example: :Pydoc collections (also works over the current word with vim's default help keybinding: Shift-K).


Comment and uncomment code with \ci.


Easy tab navigation:


tt = new tab and leaves the cursor waiting to specify the file path to open (leave blank to open an empty tab).

tn or Ctrl-Shift-Right = next tab.

tp or Ctrl-Shift-Left = previous tab.

tm = move current tab to a specific position (or to the end if no position number is specified).

tl = show a list of current tabs with their inner windows on a side pane. You can navigate them!

ts = duplicate current tab.

The mappings starting with the t letter work only on command mode, but the mappings with Ctrl-Shift work on both, command and insert mode.


Easy window navigation using Alt-arrows keys.


Some vim goodies enabled by default:


incremental search (moves to the first result while you are typing).

highlighted search results.

line numbers.

keep cursor 3 lines away from screen border while scrolling.

shell-like autocompletion of commands and paths (autocomplete the common part and show matching options).

syntax highlighting on by default.

Python interpreter inside vim, or any other console. They are opened as a buffer using the command :ConqueTerm. Examples: :ConqueTerm python, :ConqueTerm bash.


Save current file as sudo using :w!!.


Navigate html/xml tags the same way that you navigate (), {} and []: using %.


Beautiful status line allways visible, with colors, breadcrumbs and useful information about file type, encoding and position. When working with python files, it also displays the current python function or class where the cursor is.


Automatically removes trailing spaces when saving python files.


Smart autoclosing of (, [, and {


Beautiful color schemes for on vim with 256 colors (fisa colorscheme) and gvim (wombat colorscheme).


Use of 256 colors when possible.


2 spaces indentation for html and javascript (can disable it removing two lines from the .vimrc).


Thousands of code snippets for many languages with SnipMate. Example, in python you can write cl and press tab (while in inser mode), and it will insert the boilerplate code of a common python class (then use tab to navigate the snippet fields).


Zen coding for html: generate lots of html code writing simple and short expressions. Example:


write #books>ul>li.book*5>a


press Ctrl-y ,


it will generate:


<div id="books">

    <ul>

        <li class="book">

            <a href=""></a>

        </li>

        <li class="book">

            <a href=""></a>

        </li>

        <li class="book">

            <a href=""></a>

        </li>

        <li class="book">

            <a href=""></a>

        </li>

        <li class="book">

            <a href=""></a>

        </li>

    </ul>

</div>


Git and other vcs integration, with commands such as: :GitStatus, :GitDiff, :GitBlame, :GitLog, :GitCommit, or simply :Git with your own command. Key mappings and syntax highlighting for git displays. Displays icons on the side of each line based on the result of a diff of the current file (example: if you added a line and still didn't commit the file, that line will have a green + on its side). And finally, when on a changed file you can jump through changes using \sn and \sp.


Better python indentation.


Really neat surround actions using the surround.vim plugin. Learn how to use it here.


Indentation defined text objects for the editing language, named i. For example, you can change an entire indented code block with cii, or the indented block and its header line with cai (also yank, delete, ...).


Indentation based movements, move to the header of your current python block with [-, to the end of the block with ]-, and more (short reference here).


Python class and method/function text objects for the editing language, named C and M. For example, you can change an entire function content with ciM, or delete a class including its header with daC.


Run the current python file and display the output on a split with \r.


Insert and remove ipdb breakpoints with \b.


Copy history navigation using the YankRing plugin, which allows you to cicle the vim clipboard with Ctrl-p and Ctrl-n, and many other features (described here).


Insert ipdb breakpoints with \b.


Automatically sort python imports using :Isort.


Persistent undos modify file, exit vim, reopen file, and you can undo changes done on the previous session.


Better paths for temporary swap files, backups, and persistent undos (all of them stored under ~/.vim/dirs).


Drag visual blocks (blocks selected on Ctrl-v and Shift-v visual modes) with Shift-Alt-arrows, or even duplicate them with D.


Simple window chooser: press - and you will see big green letters for each window. Just press the letter of the window you want to activate.


Paint css color values with the actual color.


Format Python code using yapf (:YapfFullFormat formats the whole file, and has other commands as well, explained here. Works only if you have a vim compiled with python 2, not python 3).


Custom configs by folder add a .vim.custom file in the project's root folder with whatever configs you want to customize for that project. For example, if you have a project tree like this example and you want to exclude folder_x from FuzzyFinder, put let g:ctrlp_custom_ignore["dir"] = g:ctrlp_custom_ignore["dir"] . '|\v[\/]folder_x$' in the .vim.custom file.


project

├── folder_1

├── folder_2

├── folder_x

└── .vim.custom

[팁] tortoiseSVN의 blame 기능

2014. 8. 25. 14:35 | Posted by 꿈꾸는코난

TortoiseSVN Blame  기능

 

히스토리 볼 파일을 선택하고, TortoisSVN -> Blame을 선택하면 된다.

 

손쉽게 특정 라인은 누가 checkin했는지와 히스토리를 라인 단위로 볼 수 있다.

 

 

http://tortoisesvn.net/docs/nightly/TortoiseSVN_sk/tsvn-dug-blame.html

 

 

[유틸] PowerMockup

2014. 2. 10. 14:51 | Posted by 꿈꾸는코난

인터넷을 뒤지다 우연히 발견한 PowerMockup

 

www.powermockup.com

 

위 싸이트에서 Free Trial 버전을 받아 설치하면 PowerPoint에서 바로 사용할 수 있다.

 

 

 

대략 보면 알겠지만 powerpoint에서 쉽게 mockup을 작성하기 위한 툴이라고 생각하면 된다. 사실 mockup을 만들기 위해 Powerpoint 기본 도구로 손보기에는 시간도 많이 소요되고 만족할 만한 디자인이 나오지 않는다.

하지만 powermockup을 사용하게 되면 기본적인 많은 stencil이 있기 때문에 쉽게 가져와서 사용할 수 있다는 잇점이 있다.

다만 trial version을 각 카테고리별로 3개씩만 사용할 수 있다는 단점이 있다.

 

홈페이에 있는 개략적인 소개를 보면,

 

먼저 powermockup을 이용한 mockup.

 

 

기본적인 기능 설명

 

 

 

전체 기능을 다 사용해 보면 좋을 것 같다.

 

cygwin에서 mongo db 설치하고 사용하기

 

테스트를 위해 cygwin에서 mongo db 설치하고 테스트 해 보기로 했다.

근데 cygwin에서 어플을  수행하기 위해서는 별로 cygwin 환경에 맞추어진 바이너리를 설치해야 한다고 생각했다.

그래서 cygwin 환경에 많는 설치 패키지를 찾기 위해 검색을 했는데 그 결과는 예상밖이었다.

별로 설치 패키지 없이 윈도우용 mongo db 패키지를 설치하고, 그걸 cygwin 환경에 맞게 복사만 해주면 되는 거였다.

 

차례대로 보면.

 

1. mongo db 설치하기

   -. www.mongodb.org/downloads 에서 설치패키지 다운로드

     

     

 

2. 패키지 압축 풀기

    -. mongodb-win32-x86_64-2008plus-v2.0-latest.zip 압축 풀기

 

3. 바이너리 파일 복사

    -. 압축 푼 디렉토리 안에 있는 bin 폴더 안의 모든 파일을 다음 디텍토리로 복사

       c:\cygwin\usr\local\bin

 

4. 테스트

    -. mongod 실행

 

 

    -. mongo 실행 

 

특별한 추가작업없이 정상적으로 잘 동작하는 것을 확인할 수 있었다.

 

 

[팁] cygwin에서 libpcap 사용

2013. 7. 8. 18:02 | Posted by 꿈꾸는코난

cygwin을 설치하고 여러가지 테스트해 보던 중 tcpreplay를 설치해 보기로 헀다.

그런데 tcpreplay 소스를 받아서 빌드해 볼려고 하니 libpcap이 없어서 빌드가 되지 않는다.

libpcap을 설치하기 위해 구글링을 해보니 다음과 같은 방법이 있었다.

 

1. Setup Winpcap

 

1. Download and unzip the pack. We will use for this example WpdPack_4_0_1.zip.
2. Copy libraries like this:
  • WpdPack\Lib\libpacket.a to cygwin\lib\
  • WpdPack\Lib\libwpcap.a to cygwin\lib\

3. Create a folder cygwin\usr\include\pcap\
4. Copy all headers from WpdPack\Include to cygwin\usr\include\winpcap\
5. Be sure you have installed Winpcap libraries and that they are in your path by 

    typing:

  • which Packet.dll
  • which wpcap.dll

 

2. Building example using cygwin

 

< basic_dump > CFLAGS="-g -Wall -mno-cygwin -I /usr/include/pcap"
LIBS="-lwpcap"
PROG="basic_dump"
gcc $CFLAGS -c $PROG.c
gcc $CFLAGS -o $PROG.exe $PROG.o $LIBS
./$PROG.exe

 

위 과정을 거쳐 libpcap은 정상 설치 가능하다.

 

그러나 tcpreplay를 설치하기 위해서는 가야할 길이 험난하다.

없는 라이브러리도 많고... 일단 보류해야 겠다.

 

 

[팁] cygwin에서 proftpd 사용하기

2013. 6. 28. 13:26 | Posted by 꿈꾸는코난

회사에서 테스트를 위해 cygwin을 깔아서 이것 저것 테스트를 진행해 봤다.

유틸리티나 컴파일 등은 아무런 문제없이 잘 되는데 유독 서버 프로그램들(FTP, HTTP) 등은 잘 동작하지 않는 것을 확인했다.

분명  설치되어 있는 걸 보면 동작은 할텐데...

싸이트를 뒤지다 보니 별도의 서버를 돌려야지만 이러한 서버 프로그램이 동작한다는 것을 알게 되었다.

 

1. 설정파일 변경(/etc/proftpd.conf)

 

# Set the user and group under which the server will run.
User                            SYSTEM
Group                           Administrators

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot ~

 

2. 서버를 서비스로 기동

 

cygrunsrv --install proftpd \
          --path /usr/sbin/proftpd.exe \
          --args "--nodaemon" \
          --type manual \
          --disp "CYGWIN proftpd" \
          --desc "ProFTPd FTP daemon"

 

3. 서버 시작

 

cygsrunsrv --start proftpd

 

이렇게 해놓고 FTP 접속해 보면 잘 접속되는 것을 알 수 있다.

 


인증서 형식변환

PKCS#12 에서 개인키 추출
> openssl pkcs12 -in nine4u.pfx -nocerts -nodes -out nine4u.key

PKCS#12 에서 인증서 추출
> openssl pkcs12 -in nine4u.pfx -nokeys -out nine4u.crt

PEM -> PKCS#12
> openssl pkcs12 -export -in nine4u.crt -inkey nine4u.key -out nine4u.p12

DER => PEM
> openssl rsa -inform DER -outform PEM -in nine4u.der -out nine4u.pem

PEM => DER
> openssl rsa -inform PEM -outform DER -in nine4u.pem -out nine4u.der

[팁] vmware 가상드라이버 생성

2011. 7. 15. 14:28 | Posted by 꿈꾸는코난

vmware에서 가상 머신을 사용하다 보면 어느순간 가상디스크가 부족한 경험을 하게 된다. vmware에서는 가상디스크를 늘리는 옵션을 제공하지만 시간도 오래 걸리고 잘못하면 기존 데이타가 깨지지 않을까 하는 걱정을 하게 된다.
이때는 기존 가상 디스크를 늘리지 말고 새로운 가상 디스크를 하나 추가한 다음 새로 만든 가상 디스크를 마운트해서 사용하면 된다.

사용 방법은

0. 해당 vm 종료

1. Virutual Machine Setting에서
    -. Add... -> Hard Disk -> 원하는 사이즈  선택

2. 해당 vm 부팅 후 추가된 hard disk 포맷

$>fdisk /dev/sdb
command(m for help) : n
p
Partition number (1-4) : 1
First vylinder : Enter
Last cylender : Enter

command (m for help) : w

$>mkfs.ext3 /dev/sdb1
$>mkdir /data
$>mount /dev/sdb1 /data
$>df -h

 

[팁] Win7 관리자 권한 활성화

2011. 6. 29. 13:30 | Posted by 꿈꾸는코난


여태 Vista나 Win7을 사용하지 않다가 두달 가량 Win7을 사용하고 있다. 여전히 익숙치는 않지만 그럭저럭 사용을 하고 있는데 여전히 적응되지 않는 부분이 "관리자 권한 실행"이다. 뭐 그정도는 불편하더라도 감수한다고 치자. 근데 내가 Vista와 Win7을 Synergy로 연결해서 키보드랑 마우스를 공유하고 있는데, 몇몇 어플리케이션에서 화면 전환이 되면 연결이 끊어진다는 것이다. 그러면 그 창을 닫으면 다시 괜찮아지고..
그래서 인터넷을 뒤져 좀 편하게 사용할 방법이 없을까 찾던 중 그 답을 찾았다.

일단 Vista나 Win7은 기본적으로 Administator 계정이 잠겨 있어서 사용할 수 없다는 것이다. Win7 설치시 계정을 만들고 Administrator 권한을 줘도 이 계정은 Administrator 계정이 아니라는 말이다. 따라서 가장 좋은 방법은 설치시 생성한 계정을 사용하지 않고 시스템에서 제공하는 Administator 계정을 사용하는 것이다.

일단 관리자 권한으로 cmd 창을 연 다음에...

net user administrator /active:yes 

끝이다. ㅎㅎ. 단 다시 Win7을 껐다 켠 다음에 Administrator 계정으로 로그인한 다음 사용자 관리에서 비밀번호 입력하면 끝난다.
확인해 보니 Synergy 끊어지는 현상도 사라지고 괜찮은 것 같다.

단 위 방법은 Home Premimum에서만 동작하며(사실 다른 버전에서 동작하는지는 모르겠다) 인터넷 블로그를 찾아보면 나머지 버전은 다른 방법으로 Administrator 계정을 활성화 시키는 것 같다.

이전 1 2 다음