ssh
네트워크
쓰는 꼴
ssh [-p <port>] <user>@<host> [command]다른 기계에 암호화된 셸을 엽니다 — 비밀 키 파일이 남에게도 읽히면 ssh는 아예 거부하니 `chmod 600`이 필요하고, 포트는 여기서 `-p`인데 scp와 sftp에서는 `-P`입니다.
자주 쓰는 옵션
| 옵션 | 뜻 |
|---|---|
| -p 2222 | Port. Note that scp and sftp spell the same thing -P. |
| -i ~/.ssh/id_ed25519 | Use a specific private key. |
| -L 8080:localhost:80 | Local forward: your port 8080 reaches the remote side. |
| -R 9000:localhost:3000 | Remote forward: their port 9000 reaches your machine. |
| -D 1080 | A local SOCKS proxy tunnelled through the host. |
| -J <bastion> | Jump through a bastion host in one command. |
| -N -f | No remote command, go to the background. The pair used for tunnels. |
| -v / -vvv | Show the handshake, which is how you find out why a key was refused. |
| -o <Option>=<value> | Any ssh_config setting for this one connection. |
예시
ssh -p 2222 deploy@example.comLog in on a non-standard port.
ssh -N -L 5432:localhost:5432 deploy@db.example.comReach the remote database as if it were local.
ssh -vvv git@github.comSee exactly which keys were offered and rejected.
연결이 안 될 때 어디까지 갔는지 좁혀 갑니다 — 이름이 안 풀리는지, 길이 없는지, 포트가 막혔는지.
읽는 방법
- 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
- 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
- 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.
자주 묻는 것
Q. ssh은 무엇을 하나요?
다른 기계에 암호화된 셸을 엽니다 — 비밀 키 파일이 남에게도 읽히면 ssh는 아예 거부하니 `chmod 600`이 필요하고, 포트는 여기서 `-p`인데 scp와 sftp에서는 `-P`입니다.
Q. 어떻게 치나요?
ssh [-p <port>] <user>@<host> [command] — 대괄호는 생략할 수 있는 자리입니다.
Q. 옵션은 몇 개나 자주 쓰나요?
여기 정리한 것은 9개입니다. 전체 목록은 man ssh에 있습니다. 이 명령은 네트워크 갈래입니다.
같이 보는 명령
man 페이지: man ssh