Ankit R Gadiya

How to setup SSH server on Debian

A tutorial to setup and configure SSH server on Debian machines.

May 15, 2016

This is a tutorial for setting up SSH server on Debian or distros based on Debain.

Steps:


  • Install the openssh-server package.
    $ sudo apt-get install openssh-server
    
  • Configure it to start at boot.
    $ sudo update-rc.d -f ssh remove
    $ sudo update-rc.d -f ssh defaults
    $ sudo update-rc.d -f ssh enable 2 3 4 5
    
  • For more security, you can change the default keys.
    $ cd /etc/ssh
    $ sudo mkdir keys_orig
    $ sudo mv ssh_host_* keys_orig
    
  • Now, generate new keys.
    $ sudo dpkg-reconfigure openssh-server
    
  • For more customisation, you can edit the sshd_config file.
    $ gedit /etc/ssh/sshd_config
    
  • After all the changes restart ssh service.
    $ sudo service ssh restart
    
  • Done!