###############
## ssh 명령어 ##
################
=================================================================
OPENSSH-LAB> ssh 를 이용해서 서버에 접속하는 방법
+--------+ +--------+
| | | |
| Client | ---> | Server |
| | | |
+--------+ +--------+
root ---> sshuser
o 일반적인 접속방법:
- 첫 번째 방법 : ssh sshuser@hostname
- 두 번째 방법 : ssh -l sshuser hostname
ksw$ ssh 1.1.1.1 <-- ksw o root x
ksw$ ssh root@1.1.1.1 <-- ksw x root o
o ssh 옵션들
usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-E log_file] [-e escape_char]
[-F configfile] [-I pkcs11] [-i identity_file]
[-L [bind_address:]port:host:hostport] [-Q protocol_feature]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-R [bind_address:]port:host:hostport] [-S ctl_path]
[-W host:port] [-w local_tun[:remote_tun]]
[user@]hostname [command]
o 서버로 접속하는 클라이언트 프로그램
**** scp 는 포트번호가 22번이 아니면 -p(소문자) 옵션을 사용한다. ****
**** 보안상 서버가 포트번호 22 를 다른 포트 (2200) 로 변경할때는
**** alias 를 이용하면 편리하게 접속할 수 있다.
**** # alias ssh='ssh -p2200'
- 사용자를 생성한다.
Server# useradd sshuser ; echo 1234 | passwd --stdin sshuser
- 접속방법 1 (이메일 형식으로 접속하는 방법)
- Server 가 보내준 공개키를 Client는 $HOME/.ssh/known_hosts 파일에 저장되어 있다.
Client# ssh sshuser@localhost
sshuser@localhost's password: <-- 1234 입력
Server$ id
uid=525(sshuser) gid=525(sshuser) groups=525(sshuser) ...
Server$ exit
- 접속방법 2 (-l 옵션으로 접속하는 방법)
Client# ssh -l sshuser localhost
sshuser@localhost's password: <-- 1234 입력
Last login: Wed Apr 16 20:54:18 2014 from localhost.localdomain
Server$
=================================================================