Remote access to Ubuntu machine via ssh. Commands.

Task List:

  1. Check that any SSH services are installed on the remote Linux machine

    1
    dpkg -l | grep ssh
  2. Check for the correct cervice name
    Run the following command to list all available services related to SSH:

    1
    systemctl list-units --type=service | grep ssh

    You might see service names like:

    • ssh.service
    • sshd.service
    • openssh-server.service
  3. Check that openssh-server is installed

    1
    sudo apt-get install openssh-server
  4. Verify the installed openssh-server configuration

    1
    sudo systemctl status sshd
  5. Check secure SSH access via the configuration file

    1
    sudo nano /etc/ssh/sshd_config
  6. Confirm that openssh-server is running

    1
    sudo systemctl start sshd && sudo systemctl enable sshd
  7. Test SSH connection from a remote system

    1
    ssh username@<remote_machine_ip>
  8. Transfer files using SSH from <local_machine> to <remote_machine>

    1
    scp /path/to/local/file username@<remote_machine_ip>:/path/to/remote/destination

Additional Commands:

  1. Restart the SSH service after making configuration changes

    1
    sudo systemctl restart sshd
  2. Check the active SSH sessions on the remote machine

    1
    who | grep ssh
  3. Allow only key-based authentication for SSH connections

    1
    2
    3
    4
    sudo nano /etc/ssh/sshd_config
    # Change the following:
    # PasswordAuthentication no
    # PermitRootLogin no
  4. Monitor SSH access logs

    1
    sudo tail -f /var/log/auth.log
  5. Put the syste to suspend, by power management (alias pm):

    1
    sudo pm-suspend
  6. Put the syste to suspend by systemctl:

    1
    sudo systemctl suspend