CCcam/OScam Server Codes: Configuration & Setup Guide
Server codes are the backbone of peer-to-peer authentication in CCcam and OScam. If you're setting up your first connection or troubleshooting why peers aren't accepting your connection, understanding how server codes work is essential. This guide covers the real technical details—the exact file paths, commands you'll actually run, and why things fail when they do.
What Are Server Codes in CCcam and OScam?
Definition and Purpose
A server code is a cryptographically generated authentication token that identifies your CCcam or OScam instance to remote peers. Think of it like a machine fingerprint—unique, time-sensitive, and tied to your installation's DES encryption key.
Server codes replaced simple username/password authentication because they're harder to brute force. Instead of transmitting credentials over the network, the code itself proves you own the installation without exposing a password. The peer verifies the code matches the node ID they expect, and the connection is accepted or rejected in milliseconds.
Difference Between CCcam and OScam Server Codes
Both systems use DES-based code generation, but they implement it differently. CCcam codes are generated by the CCcam binary itself using a proprietary algorithm tied to the CCcam version and your system's hardware ID. OScam codes come from the oscam binary and use a different DES implementation, though the concept is identical.
The practical difference: a CCcam server code won't work as an OScam code and vice versa. You can't mix them in the same configuration. If you're running CCcam, you extract and use CCcam codes. OScam installation? You get OScam codes from oscam.log.
How Server Codes Enable Peer Connections
When you connect to a peer, here's what happens. Your instance sends its server code. The peer checks it against their whitelist of known codes. If it matches a node ID in their config, the connection opens. If it doesn't match, the connection is rejected and logged as an authentication failure.
This is why server codes must be exact—a single corrupted character and the peer's DES verification fails. The peer doesn't accept partial matches or "close enough" codes.
Security Implications of Server Code Sharing
A server code identifies your entire installation. If you share it with a peer, they can authenticate as you. If that code leaks publicly or falls into untrusted hands, anyone can impersonate your node. This is why codes should only be shared with peers you explicitly authorize.
The upside: codes aren't permanent. Restart CCcam or OScam, and a new code is generated. The old code becomes invalid immediately. This makes code compromise recoverable—you're not stuck with a breached credential like a password.
CCcam Server Code Format and Syntax
Standard CCcam Code Structure Breakdown
A typical CCcam server code looks like this (anonymized example):
A1 B2 C3 D4 E5 F6 G7 H8 I9 J0 K1 L2 M3 N4 O5 P6
That's 16 bytes in hexadecimal format. The entire code is always 16 bytes—never shorter, never longer. Each pair of characters is one byte. This consistent length makes parsing reliable across platforms.
The code is output by CCcam after DES encryption of your node's key material. The resulting 16 bytes are what gets displayed and shared with peers. You won't see the unencrypted key—only the encrypted output.
Node ID and DES Key Components
Behind the scenes, your node ID and DES key are combined during code generation. The node ID is a numeric identifier you configure (or one that's auto-assigned). The DES key is derived from your installation—typically a combination of the binary version, system MAC address, and other hardware identifiers on ARM boxes.
This is why codes differ between machines. If you copy your CCcam binary from one device to another, you'll get different codes because the hardware signatures are different. The DES encryption produces different output for different inputs.
Checksum Calculation and Validation
CCcam doesn't publish its exact checksum algorithm, but the code is validated by recalculating it. When a peer receives your code, they run the same DES operation on their end using the node ID you claimed. If their output matches yours, authentication succeeds. If not, the connection is rejected.
This is why time synchronization matters. Some versions of CCcam incorporate a timestamp into the DES calculation. If your system clock is way off, the peer's checksum won't match yours.
Reading Code Output from CCcam Logs
Your CCcam server code is logged when the service starts. Check /tmp/cccam.log on most Linux installations:
grep "server code" /tmp/cccam.log
You'll see output like:
18:45:32 CCcam started
18:45:35 My code is: A1 B2 C3 D4 E5 F6 G7 H8 I9 J0 K1 L2 M3 N4 O5 P6
Some versions log it as "Node code" or just "code is". The exact wording varies by CCcam version. The important part: 16 hex bytes in sequence.
If you don't see a code line in the log, either CCcam didn't start cleanly, or the log is rotated and old. Restart the service and watch the log output in real time.
Code Expiration and Refresh Cycles
CCcam codes don't have a fixed expiration. They're static until you restart the service. However, some server codes include a time component that peers might validate against. If your system clock drifts significantly, a peer might start rejecting your code even though you haven't restarted.
Restarting CCcam forces code regeneration. The new code invalidates the old one immediately. No peers will accept the old code once your service is back online.
There's no manual "refresh code" command. You either restart the service or wait until the configured code refresh interval (if your version supports one—most don't).
Generating and Retrieving Server Codes
Extracting Code from CCcam via Telnet (Port 16001)
The fastest way to get your server code is telnet into CCcam's management port. Default port is 16001:
telnet localhost 16001
You'll see a prompt. Type:
code
The response is your current server code. This method works even if the log file is missing or rotated. It's the most reliable way to verify your code right now.
If telnet times out, verify CCcam is actually running and the port isn't blocked by a firewall. On Docker or containerized setups, make sure port 16001 is mapped correctly.
Finding Code in OScam oscam.log File Location
OScam writes its code to the oscam.log file. Paths vary by installation, but common locations are:
/var/etc/oscam/oscam.log
/etc/oscam/oscam.log
/tmp/oscam.log
Search for the code line:
grep -i "code" /var/etc/oscam/oscam.log | tail -20
Look for a line containing "code is" or "node code" followed by 16 hex bytes. OScam typically logs it once at startup:
[oscam] My code is: 12 34 56 78 9A BC DE F0 11 22 33 44 55 66 77 88
If oscam.log doesn't exist or is empty, OScam might not be logging properly. Check that the oscam user has write permissions to the log directory. Restart OScam and immediately tail the log to catch the startup message.
Generating New Codes via Restart vs. Manual Methods
Restart the service:
systemctl restart CCcam
orsystemctl restart oscam
Watch the logs immediately after:
tail -f /tmp/cccam.log
ortail -f /var/etc/oscam/oscam.log
You'll see the new code within seconds. There's no manual code generation command. The binary generates it automatically on startup by reading your node ID, hardware info, and the system clock.
If you need a new code but don't want to interrupt service, some setups use process managers or clustering that allow graceful restarts. But the result is always the same: new restart, new code.
Tools for Code Analysis and Validation
You can validate the format of a server code without connecting to peers. A valid code is always:
- 16 bytes (32 hex characters)
- Hexadecimal only (0-9, A-F)
- Typically space-separated (e.g., AA BB CC DD...) or continuous (AABBCCDD...)
Use grep with regex to validate:
echo "A1 B2 C3 D4 E5 F6 G7 H8 I9 J0 K1 L2 M3 N4 O5 P6" | grep -iE '^([0-9A-F]{2} ){15}[0-9A-F]{2}$'
If the pattern matches, the format is valid. This doesn't verify the code is cryptographically correct, just that it's formatted properly.
Cross-Platform Code Generation Differences (Linux/ARM/Enigma2)
CCcam binaries are compiled for different architectures: x86 Linux, ARM (popular on set-top boxes), and Enigma2 (proprietary Linux variant). Each binary generates different codes even with the same node ID and clock because the hardware ID signature is different.
This is why you can't copy a code from an Enigma2 box to a Linux PC and expect it to work. The binary itself is part of the DES calculation. An Enigma2 code only works on Enigma2 hardware running that specific binary version.
If you're migrating from one platform to another (e.g., old Enigma2 box to a Linux server), you must get new codes from the new platform. You can't reuse the old codes.
Configuring Server Codes in CCcam.cfg and oscam.conf
Adding Peer Codes to CCcam.cfg Syntax
You don't store your own code in CCcam.cfg. Instead, you store your peers' codes. Here's the peer section structure:
[peer]
hostname = peer.example.com
port = 16001
code = A1 B2 C3 D4 E5 F6 G7 H8 I9 J0 K1 L2 M3 N4 O5 P6
nodeid = 0x12345678
The code line is where your peer's server code goes. The nodeid is what your CCcam will expect that peer to identify as. When the peer connects, they send their code. Your instance validates it matches the nodeid and code you've configured.
Multiple peers need multiple [peer] blocks:
[peer]
hostname = peer1.example.com
port = 16001
code = AA BB CC DD EE FF 00 11 22 33 44 55 66 77 88 99
nodeid = 0x11111111
[peer]
hostname = peer2.example.com
port = 16001
code = 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF 00
nodeid = 0x22222222
Spacing and capitalization matter. Use uppercase hex (or lowercase—both work). Ensure the code is exactly 16 bytes with proper spacing or it will fail parsing.
OScam Cardsystem Configuration with Server Codes
In OScam's oscam.conf, server codes are referenced differently. OScam uses a card system declaration:
[cccam]
port = 16001
[reader]
label = remote_peer
protocol = cccam
device = peer.example.com,16001
code = A1 B2 C3 D4 E5 F6 G7 H8 I9 J0 K1 L2 M3 N4 O5 P6
nodeid = 0x12345678
The code line in the [reader] section identifies your peer. When OScam connects, it sends its own code and expects to receive the peer's code. If they don't match what's configured, the connection fails.
OScam's code validation is stricter than CCcam's in some versions. Whitespace, case, and exact formatting matter. If a connection fails, check that the code in oscam.conf matches character-for-character what the peer is sending.
Port Configuration (Default 16001, 16002 Alternatives)
Port 16001 is the default for CCcam peer connections. Some setups use 16002 as an alternative, but this requires configuration on both sides.
To use a non-default port in CCcam.cfg:
[peer]
hostname = peer.example.com
port = 16002
code = A1 B2 C3 D4 E5 F6 G7 H8 I9 J0 K1 L2 M3 N4 O5 P6
nodeid = 0x12345678
The peer's instance must also be listening on port 16002. If the peer only listens on 16001 and you're trying to reach them on 16002, the connection will timeout.
Firewall rules must allow the port. Many ISPs block 16001 by default. If you can't connect, try checking if the port is reachable:
telnet peer.example.com 16001
If that times out, the port is likely blocked. Switching to a higher port (above 50000) sometimes bypasses ISP filters, but both sides need to agree on the port number.
Bounce and Reshare Settings with Code Validation
Server codes are validated on every connection, not just the initial handshake. This matters for bounce and reshare configurations where your CCcam relays connections through multiple peers.
In a bounce setup:
[peer]
hostname = bounce.example.com
port = 16001
code = 99 88 77 66 55 44 33 22 11 00 FF EE DD CC BB AA
nodeid = 0x87654321
bounce = 1
The code must be correct for every hop. If the bounce peer's code changes (e.g., they restart), your connection will fail until you update the code in your config. This is why monitoring logs for authentication failures is critical in bounce setups.
Reshare (multiple cards, distributed to multiple peers) works similarly. Each peer connection requires valid server codes.
Testing Connections After Code Input
After adding a peer with their server code, test the connection immediately:
systemctl restart CCcam
sleep 5
tail -f /tmp/cccam.log | grep peer.example.com
Look for a line like:
connected to peer.example.com:16001
authenticated code match
If you see "authentication failed" or "code mismatch", the code is wrong or the peer rejected it. Verify the code matches exactly what the peer sent you.
In OScam, check oscam.log:
tail -f /var/etc/oscam/oscam.log | grep "remote_peer"
Look for "connected" or "authenticated" messages. Connection errors will appear clearly with timestamps.
Troubleshooting Server Code Issues
Code Mismatch and Connection Failures
The most common issue is a typo in the code. A single wrong character breaks authentication. Always copy/paste codes rather than typing them manually. If you must type, use a code validation script to verify before restarting the service.
If a connection fails, extract both your code and the peer's code and compare byte by byte:
echo "Your code: A1 B2 C3 D4 E5 F6 G7 H8 I9 J0 K1 L2 M3 N4 O5 P6"
echo "Peer code: A1 B2 C3 D4 E5 F6 G7 H8 I9 J0 K1 L2 M3 N4 O5 P7"
See the difference at the end? P6 vs. P7. That's a code mismatch. The peer will reject the connection.
Expired or Stale Codes
Codes aren't technically "expired" in the way a password might be. However, if a peer restarts their service, their code changes. You won't know about it unless they contact you. Your config still has the old code, so connections will fail.
The solution: ask the peer for their current code and update your config. If the peer restarts frequently and doesn't notify you, consider using a dynamic update mechanism or a script that polls for new codes periodically.
To detect stale codes in logs, look for persistent authentication failures with a specific peer:
grep "authentication failed" /tmp/cccam.log | tail -20
If you see the same peer failing repeatedly over the last hour, their code likely changed.
Platform Compatibility Problems
A code generated on an Enigma2 box won't work if you move the installation to Linux. The binary is different, the hardware signature is different, and the DES output is different.
Similarly, CCcam 2.1.x and 2.2.x might generate slightly different code formats on the same hardware. If you're upgrading CCcam, extract a new code after the upgrade and redistribute it to peers.
To verify the platform:
file /usr/bin/cccam
This shows the binary type (x86, ARM, etc.). If a peer is on a different platform, their code format might not be directly compatible with your installation's validation logic.
Firewall and NAT Issues Blocking Code Authentication
Even if the code is correct, the connection fails if the firewall blocks port 16001 or 16002. The code authentication never happens because the TCP handshake fails first.
Test reachability before worrying about codes:
telnet peer.example.com 16001
If this hangs or times out, the port is blocked. The code is irrelevant.
Behind NAT? The peer needs to port-forward 16001 (or your custom port) to their internal IP. If they don't, their code is unreachable from the internet even though it's correct.
Confirm the peer's port is open and reachable from outside:
nmap -p 16001 peer.example.com
If the port is filtered or closed, firewall/NAT is the issue, not the code.
Log Analysis for Code Rejection Errors
CCcam logs authentication decisions in /tmp/cccam.log. Search for rejection messages:
grep -i "reject\|fail\|error" /tmp/cccam.log | grep -i code
Messages vary by version, but look for:
- "code mismatch"
- "authentication failed"
- "invalid code"
- "peer rejected"
These indicate the peer either didn't recognize your code or you didn't recognize theirs. Re-verify the codes match and that both sides are using compatible binaries.
For OScam, check oscam.log similarly:
grep -i "authentication\|fail\|error" /var/etc/oscam/oscam.log
OScam messages are typically more verbose. Look for the reader name (e.g., "remote_peer") and trace what happened.
Common Misconfiguration Mistakes
Whitespace errors are common. Some editors add trailing spaces to lines:
code = A1 B2 C3 D4 E5 F6 G7 H8 I9 J0 K1 L2 M3 N4 O5 P6 [hidden space here]
The parser might reject the entire line. Use a hex editor or validate the config syntax before restarting:
cat /etc/CCcam/CCcam.cfg | od -c | grep -i code
This shows the raw bytes, including any hidden whitespace.
Case sensitivity is usually not an issue (both AA and aa are accepted), but different CCcam versions might be stricter. Stick to uppercase for consistency.
Nodeid mismatches are another trap. The nodeid is separate from the code. If you configure a nodeid in your peer entry but the peer is using a different nodeid, authentication fails. Verify both the code AND the nodeid with the peer.
Security and Best Practices for Server Codes
Server codes are sensitive. Don't post them on public forums or in pastebin. If you suspect your code has been compromised, restart your service immediately to invalidate it and generate a new one.
Only share server codes with peers you trust completely. A leaked code gives someone the ability to impersonate your installation. They can't use your card, but they can intercept connections meant for you.
Keep logs for at least 7 days so you can detect when unauthorized connections were made if a code leaks. Look for connection attempts from unknown IPs.
When removing a peer, restart your service to force code regeneration. This prevents the old peer from reconnecting with a cached code (though this is unlikely in practice).
For production setups with many peers, consider documenting code changes in a private log file with timestamps. This helps you audit which peers have current codes and which might be stale.
Advanced: Packet-Level Analysis of Server Code Authentication
If a connection is failing and logs don't explain why, tcpdump can reveal what's actually being sent:
tcpdump -i eth0 -A host peer.example.com and port 16001
You won't see the actual code in plaintext (it's encrypted), but you can verify that data is being exchanged and that the connection isn't timing out at the TCP level.
Look for patterns: if the peer closes the connection immediately after you send data, they rejected your code. If the connection hangs and times out, the firewall or the peer's service is unresponsive.
For deeper analysis, some users run tcpdump to a file and analyze it in Wireshark, but at this level of troubleshooting you're usually hitting a known problem: wrong code, firewall, or service not running.
Docker and Containerized Deployments
If you're running CCcam or OScam in a Docker container, the server code persists across container restarts as long as the persistent volume is mounted. If you're not using a volume, the code changes every time the container restarts because the container environment is different.
To ensure stable codes with Docker:
docker run -v /opt/cccam:/root/cccam -p 16001:16001 cccam:latest
The -v /opt/cccam:/root/cccam mounts a host directory into the container. Logs and configs persist, and so does the generated code (assuming the binary stores the code deterministically).
Without a volume, extract the code after every restart:
docker exec cccam_container sh -c "telnet localhost 16001 <<< 'code'"
This gets the current code without needing to inspect logs. Update your peers with the new code immediately.
Q: What's the difference between a CCcam code and an OScam code?
CCcam uses its own binary-specific DES implementation to generate codes, while OScam uses a slightly different DES variant in the oscam binary. Both produce 16-byte hexadecimal codes that serve the same authentication purpose, but the underlying encryption is different. A CCcam code will never work in OScam's configuration, and vice versa. This is because the DES keys and calculation methods are distinct. If you're using both services on different machines, you need separate codes for each. They're not interchangeable.
Q: How often do server codes expire or change?
Server codes don't have a built-in expiration timer. They're static until you restart the service. Once you restart CCcam or OScam, the code is immediately regenerated and the old code becomes invalid. Some versions of CCcam include a timestamp component in the DES calculation, which means time synchronization matters—if your system clock drifts significantly, peers might start rejecting your code even without a restart. Generally, codes should be considered permanent for the lifetime of a service run, not rotated manually like passwords. The only exception is if you intentionally want to force code rotation by restarting the service.
Q: Can I use the same server code on multiple devices?
No. Codes are node-specific and tied to the binary and hardware of each installation. If you copy the same code to two different machines, conflicts will occur because the DES encryption is device-specific. Each machine must generate its own code. In Docker environments, if you clone a container and start both instances, they'll initially have the same code (because they're the same image), but as soon as one restarts, the codes diverge. To run multiple instances of CCcam on the same hardware, each must have its own node ID and will generate its own unique code.
Q: Why is my server code rejected by peers?
Several reasons: (1) The code is outdated—the peer restarted and generated a new code. Ask them for the current code. (2) Platform mismatch—your CCcam and the peer's are on different architectures (Enigma2 vs. Linux), and the code formats aren't compatible. (3) Whitespace or formatting errors in the config file—trailing spaces or mixed case can break parsing. (4) Firewall blocking port 16001 before the code validation even happens. (5) Time synchronization issues—if your system clock is far ahead or behind, the DES checksum fails. (6) The peer's nodeid doesn't match what you've configured—verify both the code AND nodeid with the peer. (7) Different CCcam versions with incompatible code generation. Check logs for "authentication failed" or "code mismatch" messages, verify the code matches character-for-character, and confirm the port is reachable.
Q: How do I validate that a server code is correctly formatted?
A valid server code is always 16 bytes of hexadecimal data (32 hex characters total). Check the format with grep: echo "A1 B2 C3..." | grep -iE '^([0-9A-F]{2} ){15}[0-9A-F]{2}$'. If the pattern matches, the format is valid. You can also count the bytes manually—if you see 16 space-separated pairs like "AA BB CC..." it's correctly formatted. To verify the code is cryptographically valid without connecting to peers, telnet into your local service and request the code directly: telnet localhost 16001 then type code. Compare your output with what you have in the config. If they match, you're good. This doesn't require contacting peers and risking rejection.
Q: What should I do if I've shared my server code and want to revoke access?
Restart your CCcam or OScam service immediately. A new code is generated automatically on startup, and the old code becomes invalid within seconds. Any peer using the old code will be unable to authenticate. The revocation takes effect instantly on your side. Peers won't reconnect successfully because their cached code no longer matches yours. This is an advantage of the code-based system—you don't need to manually change a password or update a whitelist. Simply restarting invalidates all previously shared codes. If you need to revoke access to a specific peer while keeping others, you can remove that peer's entry from your config file, but restarting is the quickest way to invalidate all codes at once. For security, restart immediately if you suspect a code has been compromised.