photo lineviral_1.png

Kali Linux Remote Ssh – How To Configure Openssh Server

Secure Shell (SSH) is a cryptographic network protocol for secure information communication, remote command-line login, remote ascendancy execution, in addition to other secure network services betwixt 2 networked computers. It connects, via a secure channel over an insecure network, a server in addition to a customer running SSH server in addition to SSH customer programs, respectively. The protocol specification distinguishes betwixt 2 major versions that are referred to equally SSH-1 in addition to SSH-2.


The best-known application of the protocol is for access to musical rhythm accounts on Unix-like operating systems, but it tin lavatory also last used inwards a similar fashion for accounts on Windows. It was designed equally a replacement for Telnet in addition to other insecure remote musical rhythm protocols such equally the Berkeley rsh in addition to rexec protocols, which mail information, notably passwords, inwards plaintext, rendering them susceptible to interception in addition to disclosure using packet analysis.The encryption used yesteryear SSH is intended to supply confidentiality in addition to integrity of information over an unsecured network, such equally the Internet.


You tin lavatory role your Android phone, remote computer, iPAD or anything to login to a SSH server in addition to execute ascendancy equally if you’re sitting on that workstation. So let’s come across how you lot tin lavatory install a SSH server (we volition last using openSSH-Server here) on Kali Linux. After this guide you lot volition last able to produce the followings:



  1. Install Kali Linux remote SSH – openSSH server

  2. Enable Kali Linux remote SSH service on boot

  3. Change Kali default ssh keys to avoid MITM attack

  4. Set MOTD – Message of the Day message amongst a overnice ASCII

  5. Troubleshoot in addition to railroad train “WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED” mistake during SSH session.

  6. Change SSH server port for extra safety



Step 1: Install Kali Linux remote SSH – openSSH server


Issue the next ascendancy on Kali Linux terminal to install openssh-server.


root@kali :# apt-get install openssh-server

 is a cryptographic network protocol for secure information communication Kali Linux remote SSH – How to configure openSSH server


Now the adjacent logical pace is to enable ssh server (as you lot tin lavatory come across I’ve issued the next ascendancy above).


root@kali :# service ssh start

It works, but there’s a problem. If you lot restart your Kali Linux machine, SSH server volition last disabled.


So nosotros volition ensure that SSH server remains upwardly in addition to running all the fourth dimension (even later on restart). Please depository fiscal establishment notation that if you lot don’t desire this to happen, in addition to then skip Step 2 in addition to motility to Step 3. Why? Because if you lot enable SSH server on your machine, that way your automobile volition last available via cyberspace in addition to anyone who knows your password (or your password is simply ‘123’ or ‘password’ tin lavatory suspension into your machine). So role a secured password in addition to if non certain skip to Step iii for now. Anyway, moving on..


Step 2: Enable Kali Linux remote SSH service


Now nosotros are close to enable SSH service in addition to proceed that running the whole time. (changes wont larn lost later on boot).


First of all take run levels for SSH.


root@kali :# update-rc.d -f ssh remove

Next charge SSH defaults to run level


root@kali :# update-rc.d -f ssh defaults

Check if SSH service is upwardly in addition to running


root@kali :# chkconfig ssh

 is a cryptographic network protocol for secure information communication Kali Linux remote SSH – How to configure openSSH server


If you lot don’t receive got chkconfig installed, install via


root@kali :# apt-get install chkconfig

You tin lavatory run chkconfig to come across a lot to a greater extent than too:


root@kali :# chkconfig -l ssh
(or)
root@kali :# chkconfig -l


Step 3: Change Kali default ssh keys to avoid MITM attack


At this betoken you lot volition receive got openssh-server installed on Kali Linux in addition to enabled at runlevel 2,3,4 in addition to 5. But instantly nosotros got a problem. Every Linux organisation that you lot install via a CD or DVD or similar uses a default SSH key. This is same for all kickoff installation that means, anyone amongst a similar version tin lavatory perform a Man inwards the Middle Attack (MITM) in addition to nous to your encrypted traffic. To railroad train that nosotros volition produce the followings:


Note: At to the lowest degree ane reader confirms that this pace is non necessary inwards novel Kali Linux installation equally the keys are unlike for each installation. I volition exit the determination of changing default SSH keys to the readers.


Step 3.1: Move the default Kali ssh keys to a novel folder:


Issue the next commands ane occupation at a time:


root@kali: #  cd /etc/ssh/
root@kali:/etc/ssh# mkdir default_kali_keys
root@kali:/etc/ssh#
root@kali:/etc/ssh# mv ssh_host_* default_kali_keys/
root@kali:/etc/ssh#

This volition motility your default keys to the novel folder.


Step 3.2: Regenerate the keys


Use the next ascendancy to regenerate SSH keys


root@kali:/etc/ssh#  dpkg-reconfigure openssh-server
Creating SSH2 RSA key; this may convey some fourth dimension ...
Creating SSH2 DSA key; this may convey some fourth dimension ...
Creating SSH2 ECDSA key; this may convey some fourth dimension ...
[ ok ] Restarting OpenBSD Secure Shell server: sshd.
root@kali:/etc/ssh#

Step 3.3: Verify ssh cardinal hashes are different


Use the next commands to verify SSH cardinal hashes are different


root@kali:/etc/ssh#  md5sum ssh_host_*
d5dff2404dd43ee0d9ed967f917fb697 ssh_host_dsa_key
2ec88dc08f24c39077c47106aab1e7f4 ssh_host_dsa_key.pub
ab96da6ffc39267f06e7f9497c4f5755 ssh_host_ecdsa_key
614e36d18dc2c46178d19661db4dbd7b ssh_host_ecdsa_key.pub
abcc037705e48b3da91a2300d42e6a2b ssh_host_rsa_key
e26eaa1c5cff38457daef839937fcedd ssh_host_rsa_key.pub
root@kali:/etc/ssh#

Compare novel cardinal hashes to the hashes below)


root@kali:/etc/ssh#  cd default_kali_keys/
root@kali:/etc/ssh#
root@kali:/etc/ssh/default_kali_keys# md5sum *
9a09f49be320e561dc6cf95463d4378c ssh_host_dsa_key
1a52709d596569224822e870239c9298 ssh_host_dsa_key.pub
65d0af7fdc5c50f67f90cb953460ba61 ssh_host_ecdsa_key
606d1ac71100c8b38e0f87951bb94855 ssh_host_ecdsa_key.pub
c871ecf961924389f2cddbd5888b5037 ssh_host_rsa_key
99d4c4c68224900d0430f0bee9baf28e ssh_host_rsa_key.pub
root@kali:/etc/ssh/default_kali_keys#

 is a cryptographic network protocol for secure information communication Kali Linux remote SSH – How to configure openSSH server


Restart SSH.


root@kali:/etc/ssh/default_kali_keys# service ssh restart

Thanks to pentest09 for providing this fantabulous in addition to tardily to follow information on Kali Linux forum.


Step 4: Set MOTD amongst a overnice ASCII


So far, nosotros receive got installed in addition to configured Kali Linux remote SSH – openssh-server, enabled openssh-server to run on boot, changed Kali default SSH keys to avoid MITM attacks.


Now the usual SSH MOTD (Message of the Day – Banner) is boring. I desire my get upwardly on that in addition to add together some useful info. Following is what a usual MOTD looks like:


 is a cryptographic network protocol for secure information communication Kali Linux remote SSH – How to configure openSSH server


Well, that’s simply manifestly in addition to tiresome for me.


Go to http://patorjk.com/software/taag/


Type something inwards “Type Something” Box! Play around amongst the settings in addition to you lot larn a overnice ASCII art.


 is a cryptographic network protocol for secure information communication Kali Linux remote SSH – How to configure openSSH server


Edit the next file in addition to add together your text.


root@kali: # vi /etc/motd 
root@kali: # service ssh restart

Save the file in addition to restart/reload SSH … both should simply work. I’ve added blackMORE Ops equally ASCII in addition to http://technoused.blogspot.com/ equally a minute line…


 is a cryptographic network protocol for secure information communication Kali Linux remote SSH – How to configure openSSH server


So adjacent fourth dimension I endeavor to login I larn this overnice covert amongst some to a greater extent than info


 is a cryptographic network protocol for secure information communication Kali Linux remote SSH – How to configure openSSH server


Pretty cool!


Step 5: Troubleshooting


Because I changed SSH keys inwards the pump of change, (I was logged inwards before), I had this BIG alert message coming up


 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
information technology IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could last eavesdropping on you lot right instantly (man-in-the-middle attack)!
It is also possible that the RSA host cardinal has simply been changed.
The fingerprint for the RSA cardinal sent yesteryear the remote host is
26:65:52:75:81:71:a8:c5:4c:ad:b6:81:78:58:18:af.
Please contact your organisation administrator.
Add right host cardinal inwards /root/.ssh/known_hosts to larn rid of this message.
Offending cardinal inwards /root/.ssh/known_hosts:1
RSA host cardinal for localhost has changed in addition to you lot receive got requested strict checking.
Host cardinal verification failed.

It kicked me right out.


 is a cryptographic network protocol for secure information communication Kali Linux remote SSH – How to configure openSSH server


Usually this is the sign of something bad. As you lot tin lavatory come across MITM attacks does this:


 information technology IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could last eavesdropping on you lot right instantly (man-in-the-middle attack)!

This was the argue I changed Kali Linux default cardinal (You wouldn’t fifty-fifty observe MITM if you’re using the default key).


This is a rather tardily fix. You simply ask to delete the offending occupation inwards known_hosts file.


 Add right host cardinal inwards /root/.ssh/known_hosts to larn rid of this message.
Offending cardinal inwards /root/.ssh/known_hosts:1

Use the next command:


root@kali: # vi /root/.ssh/known_hosts

Following was the cardinal I had


 is a cryptographic network protocol for secure information communication Kali Linux remote SSH – How to configure openSSH server


Just delete the line, salve the file in addition to endeavor to SSH again.


 is a cryptographic network protocol for secure information communication Kali Linux remote SSH – How to configure openSSH server


and it worked.



Step 6: Change SSH server port for extra safety


As a final pace in addition to simply to last sure, you lot should also alter SSH port from 22 to something else. (any port betwixt 10000-64000 is okay)


Make a backup of existing SSH config file.


root@kali:/etc/ssh# cp /etc/ssh/sshd_config /etc/ssh/sshd_config_backup

Edit the SSH_Config file.


root@kali:/etc/ssh#  vi /etc/ssh/sshd_config

Look for the next line:


    #Port 22

Change the occupation thus it looks similar this:


    Port 10101

Restart OpenSSH server


root@kali:/etc/ssh#  service ssh restart

Next fourth dimension you lot SSH, you lot role the next command:


root@kali: #  ssh username@myhostnaname.com -p 10101

Where



  1. username@myhostnaname.com = Username in addition to Hostname where hostname tin lavatory last an IP or FQDN.

  2. -p = Port

  3. 10101 = Destination Port


Conclusion:


SSH is typically used to log into a remote automobile in addition to execute commands, but it also supports tunneling, forwarding TCP ports in addition to X11 connections; it tin lavatory transfer files using the associated SSH file transfer (SFTP) or secure re-create (SCP) protocols. SSH uses the client-server model.


The measure TCP port 22 has been assigned for contacting SSH servers. If you lot scan for this port using NMAP, you lot volition come across many servers has it opened upwardly to the footing in addition to you lot tin lavatory endeavor to bruteforce it in addition to make access.


An SSH customer programme is typically used for establishing connections to an SSH daemon accepting remote connections. Both are usually acquaint on most modern operating systems, including Mac OS X, most distributions of GNU/Linux, OpenBSD, FreeBSD, NetBSD, Solaris in addition to OpenVMS. Notably, Windows is ane of the few modern desktop/server OSs that does non include SSH yesteryear default. Some mutual SSH clients includes



  1. PuTTY

  2. Cygwin

  3. WinSCP


and they all supply similar file administration (synchronization, copy, remote delete) capability using PuTTY equally a back-end.


Both WinSCP in addition to PuTTY are available packaged to run lead off of a USB drive, without requiring installation on the customer machine. Setting upwardly a SSH server inwards Windows typically involves installation (e.g. via installing Cygwin, or yesteryear installing a stripped downward version of Cygwin amongst the SSH server.


SSH is of import inwards cloud computing to solve connectivity problems, avoiding the security issues of exposing a cloud-based virtual automobile lead on the Internet. An SSH tunnel tin lavatory supply a secure path over the Internet, through a firewall to a virtual machine.


Thanks for reading. Please share.


Buat lebih berguna, kongsi:
close