RE: lastb
"ssh:notty" /var/log/btmp entries indicate failed login attempts from the SSH port number assigned in "/etc/ssh/sshd_config".
For security reasons, the SSH port will usually have been changed to a number other than "22". So, "ssh", in this context, merely means the currently assigned (non-22) SSH port number.
Because a successful SSH certificate handshake SHOULD always be required to reach the login screen, any "ssh:notty" log entries likely result from your own failed login attempts; usually from a mistyped username. Note the IP address associated with the log entry ... it's probably your own!
"notty" means "no tty".
Learn basic security, how it works, where the logs are and how to interpret them, and where the various config files are and what the directives mean, and how to configure IPTables, before you setup and use a Linux server. Restrict logins to a "static IP address" and limit/restrick login attemps:
BASIC SSH config directives which restrict logins and only allow logins from particular users and IP addresses:
LoginGraceTime 30
MaxStartups 3:50:10
MaxAuthTries 4
PermitRootLogin no
AllowUsers YourUserName@YourIPAddress
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
PasswordAuthentication no
Don't forget to "restart" the SSH service after editing.
BASIC IPTables rules which only allow SSH connections from a particular static IP address:
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -p tcp -m tcp ! --tcp-flags FIN,SYN,RST,ACK SYN -m state --state NEW -j DROP
-A INPUT -m state --state INVALID -j DROP
-A INPUT -f -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
-A INPUT -p tcp -m tcp --tcp-flags SYN,RST SYN,RST -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,RST FIN,RST -j DROP
-A INPUT -p tcp -m tcp --tcp-flags PSH,ACK PSH -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,ACK FIN -j DROP
-A INPUT -p tcp -m tcp --tcp-flags ACK,URG URG -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,SYN,RST,PSH,ACK,URG -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,PSH,URG -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,SYN,PSH,URG -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,SYN,RST,ACK,URG -j DROP
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp -s YourStaticIPAddress -m multiport --dports SSHPortNumber -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -j DROP
-A FORWARD -j DROP
COMMIT
Dont' forget to "restore" IP tables after changes.
On a LAN, or in a "hosted" cloud environment, don't forget to secure the "private" side (network adapter). Your enemies often already have access to your network and come in through the back door.
If you are in a cloud environment such as RackSpace or DigitalOcean, and you foul up the configurations and lock yourself out, you can always go in through the console and fix it. ALWAYS MAKE COPIES OF CONFIG FILES BEFORE EDITING THEM !!!