안전한 셸 키 관리
보안성과 편의성을 높이기 위해 키 쌍을 사용하여 비밀번호 없는 SSH 인증을 구현합니다.
안전한 셸 키 관리은(는) CoddyKit의 무료 Linux Command Line Mastery 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Linux Command Line Mastery 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Linux Command Line Mastery 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
What are SSH Keys?
SSH keys are a secure way to log into a remote server without needing a password. Think of them as a digital key and lock system.
- They provide stronger security than traditional passwords.
- They offer convenience by enabling passwordless logins.
- This lesson will guide you through setting them up.
Public and Private Key Pair
An SSH key system uses two parts: a public key and a private key.
- Your private key stays on your local computer and must be kept secret. Never share it!
- Your public key can be freely shared. You place it on any server you want to connect to.
- When you try to connect, the server uses your public key to verify your private key, allowing access.
Generating Your Own SSH Keys
You create an SSH key pair using the ssh-keygen command in your terminal.
By default, it creates keys in the ~/.ssh/ directory (a hidden folder in your home directory). The most common key type is RSA.
You'll be prompted for a passphrase. This adds an extra layer of security to your private key, encrypting it. It's highly recommended!
Hands-on: Using `ssh-keygen`
Let's generate an RSA key pair. When prompted, you can press Enter to use default file locations and choose a strong passphrase (or leave it empty for no passphrase, though not recommended for security).
ssh-keygen -t rsa -b 4096Understanding Key Files
After running ssh-keygen, you'll find two new files in your ~/.ssh/ directory:
id_rsa: This is your private key. Keep it safe and never share it!id_rsa.pub: This is your public key. You'll copy this to remote servers.
The command also shows a key fingerprint, a unique identifier for your key pair.
Copying Your Public Key to a Server
To enable passwordless login, your public key needs to be on the remote server. The easiest way to do this is with the ssh-copy-id command.
It automatically appends your public key to the ~/.ssh/authorized_keys file on the server. You'll need to enter the server's password just this one time.
ssh-copy-id user@remote_hostManual Public Key Installation
If ssh-copy-id isn't available on your system, you can manually copy your public key. This involves reading your local public key and piping it to the remote server via SSH, appending it to the authorized_keys file.
Make sure the .ssh directory exists and has correct permissions on the server (chmod 700 ~/.ssh).
cat ~/.ssh/id_rsa.pub | ssh user@remote_host "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"Testing Passwordless Login
Once your public key is on the server, try logging in. If you set a passphrase, you'll be prompted for it. If not, you should connect directly without any password prompts!
This confirms that your SSH key authentication is working correctly.
ssh user@remote_hostUsing `ssh-agent` for Convenience
If your private key has a passphrase, you'll be asked for it every time you connect. The SSH agent helps by storing your decrypted private key in memory.
- Start the agent:
eval "$(ssh-agent -s)" - Add your key:
ssh-add ~/.ssh/id_rsa(enter passphrase once)
Now you can connect multiple times without re-entering your passphrase until the agent restarts.
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsaQuick Check: SSH Key Files
Which of the following files contains your public key and is safe to share with remote servers?
Recap: Secure Key Management
You've learned how to set up and manage SSH key pairs for secure, passwordless authentication.
- Generate keys with
ssh-keygen. - Understand private (
id_rsa) and public (id_rsa.pub) keys. - Copy public keys to servers using
ssh-copy-idor manually. - Use
ssh-agentandssh-addfor passphrase convenience.
SSH keys are a fundamental tool for efficient and secure remote access in Linux!
자주 묻는 질문
“안전한 셸 키 관리” 강의는 무료인가요?
네 — “안전한 셸 키 관리” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Linux Command Line Mastery 강의 전체를 잠금 해제할 수 있습니다. Linux Command Line Mastery 강의에는 총 4개의 강의가 포함되어 있습니다.
“안전한 셸 키 관리”에서 뭘 배우나요?
보안성과 편의성을 높이기 위해 키 쌍을 사용하여 비밀번호 없는 SSH 인증을 구현합니다. 브라우저에서 직접 실행하는 실습 코드로 Linux Command Line Mastery을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Linux Command Line Mastery을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Linux Command Line Mastery은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.
“안전한 셸 키 관리” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Linux Command Line Mastery 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Linux Command Line Mastery 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 네트워크 진단: `traceroute`, `nslookup`, `dig`
- 방화벽 관리: `ufw`, `firewalld`, `iptables`
- 안전한 셸 키 관리
- tcpdump로 트래픽 캡처하고 검사하기