Ssh

From 탱이의 잡동사니
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Overview

ssh 내용 정리.

-L

Local port forwarding using ssh.

로컬 포트 포워딩을 설정한다. 설정된 포트로 데이터를 전송할 경우, 접속된 원격지 포트로 데이터가 전송된다.

     -L [bind_address:]port:host:hostport
     -L [bind_address:]port:remote_socket
     -L local_socket:host:hostport
     -L local_socket:remote_socket

Example

$ ssh -L 127.0.0.1:80:intra.example.com:80 gw.example.com

-R

Remote port forwarding using ssh.

원격지 포트 포워딩을 설정한다. 원격지에서 설정된 포트로 데이터를 전송할 경우, 설정된 로컬 포트로 데이터가 전송된다.

     -R [bind_address:]port:host:hostport
     -R [bind_address:]port:local_socket
     -R remote_socket:host:hostport
     -R remote_socket:local_socket

Example

$ ssh -R 8080:localhost:80 public.example.com

Create key

ssh 를 사용하기 위해서는 ssh key 가 필요하다. 다음의 명령어로 간단하게 키 생성이 가능하다.

[stk@pchero21.com ~]$ ssh-keygen 

Generating public/private rsa key pair.
Enter file in which to save the key (/home/stk/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/stk/.ssh/id_rsa.
Your public key has been saved in /home/stk/.ssh/id_rsa.pub.
The key fingerprint is:
1c:fb:fa:f1:f7:f4:13:62:79:8e:57:45:b8:52:cb:a0 stk@pchero21.com
The key's randomart image is:
+--[ RSA 2048]----+
|             oo  |
|         .. o.   |
|        =.o+.o   |
|       o.X.o+    |
|        S X.     |
|         * +     |
|        . o      |
|         .       |
|                 |
+-----------------+

키 생성 이후, ~/.ssh 디렉토리를 확인하면 생성된 key 내용들을 볼 수 있다.

$ cd ~/.ssh

$ ls -tlr
total 16
-rw-------. 1 stk stk  397 Oct 29  2015 authorized_keys
-rw-r--r--. 1 stk stk  668 May 11 10:27 known_hosts
-rw-r--r--. 1 stk stk  416 May 11 11:01 id_rsa.pub
-rw-------. 1 stk stk 1675 May 11 11:01 id_rsa

See also

References

<references />