Unable to SSH to Ubuntu Server: Log Locally First
Have you ever encountered an issue where you are unable to SSH into your Ubuntu server, but you are sure that SSH is properly set up and you are able to log in via the desktop environment? In this article, we will explore the steps you can take to troubleshoot this issue by logging in locally and checking the SSH logs.
Logging in Locally
To log in locally, you will need to have physical access to the server or be connected to it via a remote desktop protocol such as VNC or RDP. Once you have access, follow these steps:
- Press Ctrl + Alt + F1 to switch to a virtual console.
- Enter your username and password to log in.
- Once logged in, you can switch back to the graphical interface by pressing Ctrl + Alt + F7.
Checking SSH Logs
Now that you are logged in locally, you can check the SSH logs to see if there are any errors or issues that are preventing you from connecting via SSH. The SSH logs can be found in the /var/log/auth.log file. To view this file, you can use the less or tail command:
less /var/log/auth.log
Or
tail -n 100 /var/log/auth.log
This will display the last 100 lines of the auth.log file. Look for any lines that contain the word sshd and check for any errors or issues. Some common issues include:
- Permission denied (publickey,password)
- Failed password for
- Connection closed by
Resolving SSH Issues
Once you have identified the issue, you can take steps to resolve it. Some common solutions include:
- Checking that the SSH service is running:
sudo systemctl status ssh - Checking that the SSH server is listening on the correct port:
sudo netstat -pln | grep ssh - Checking that the SSH server is configured correctly:
sudo nano /etc/ssh/sshd_config - Checking that the SSH public key is correctly configured:
sudo cat /etc/ssh/ssh_host_rsa_key.pub
In this article, we have covered the steps you can take to troubleshoot SSH issues by logging in locally and checking the SSH logs. By following these steps, you should be able to identify and resolve any issues that are preventing you from connecting to your Ubuntu server via SSH.
References
- How To Configure SSH Key-Based Authentication on a Linux Server
- How To Troubleshoot SSH Connections with auth.log on Ubuntu 14.04
- OpenSSH Server
Types of references:
- Online resources
- Books
- Articles