Home » Kali Linux remote SSH – How to configure openSSH server

Kali Linux remote SSH – How to configure openSSH server

by blackMOREOps
37 comments

Secure Shell (SSH) is a cryptographic network protocol for secure data communication, remote command-line login, remote command execution, and other secure network services between two networked computers. It connects, via a secure channel over an insecure network, a server and a client running SSH server and SSH client programs, respectively. The protocol specification distinguishes between two major versions that are referred to as SSH-1 and SSH-2.

The best-known application of the protocol is for access to shell accounts on Unix-like operating systems, but it can also be used in a similar fashion for accounts on Windows. It was designed as a replacement for Telnet and other insecure remote shell protocols such as the Berkeley rsh and rexec protocols, which send information, notably passwords, in plaintext, rendering them susceptible to interception and disclosure using packet analysis.The encryption used by SSH is intended to provide confidentiality and integrity of data over an unsecured network, such as the Internet.

You can use your Android phone, remote computer, iPAD or anything to login to a SSH server and execute command as if you’re sitting on that workstation. So let’s see how you can install a SSH server (we will be using openSSH-Server here) on Kali Linux. After this guide you will be able to do 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 with a nice ASCII
  5. Troubleshoot and fix “WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED” error during SSH session.
  6. Change SSH server port for extra safety

Step 1: Install Kali Linux remote SSH – openSSH server

Issue the following command on Kali Linux terminal to install openssh-server.

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

Kali Linux remote SSH - How to configure openSSH server - blackMORE Ops -1

Now the next logical step is to enable ssh server (as you can see I’ve issued the following command above).

root@kali~:# service ssh start

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

So we will ensure that SSH server remains up and running all the time (even after restart). Please note that if you don’t want this to happen, then skip Step 2 and move to Step 3. Why? Because if you enable SSH server on your machine, that means your machine will be available via internet and anyone who knows your password (or your password is just ‘123’ or ‘password’ can break into your machine). So use a secured password and if not sure skip to Step 3 for now. Anyway, moving on..

Step 2: Enable Kali Linux remote SSH service

Now we are about to enable SSH service and keep that running the whole time. (changes wont get lost after boot).

First of all remove run levels for SSH.

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

Next load SSH defaults to run level

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

Check if SSH service is up and running

root@kali~:# chkconfig ssh

Kali Linux remote SSH - How to configure openSSH server - blackMORE Ops -3

If you don’t have chkconfig installed, install via

root@kali~:# apt-get install chkconfig

You can run chkconfig to see a lot more too:

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

You may also like

37 comments

zimmaro_the_g0at June 20, 2014 - 5:50 pm

GOOD-WORK!!!
as always .. thank you very much MY “guru”friend :-) +1
http://www.imagestime.com/show.php/956618_Screenshot20140620093707.png.html
zimmaro_the_g0at
:-)

Reply
blackMORE Ops June 22, 2014 - 11:41 pm

Hi again zimmy,
Always a please seeing your comment. Glad you found it use of. :) Cheers,
-BMO

Reply
Julio Cesar April 15, 2015 - 11:29 pm Reply
Volkermord June 20, 2014 - 8:29 pm

wow awsome tutorial thanks you very much sir,
i have one qestion: how to set ssh to not keep the logs?
Thanks in advance.

Reply
blackMORE Ops June 22, 2014 - 11:47 pm

Hey Volkermord,
Config’s is in /etc/ssh/sshd_config file.
Set LogLevel none for no logs and restart sshd. That should do it. Some more references here and here.
Cheers,
-BMO

Reply
Tomas June 25, 2014 - 5:28 am

A little piece of advice. No matter what port you chose for SSH, make sure it’s below 1024. On Linux systems, any user can listen on ports above 1024, but only root can listen on ports below 1024. Running SSH on a port above 1024 increases a chance of crashing your SSH daemon and replacing it with some dodgy proxy etc.

Some other suggestions for “extra safety”:

Protocol 2
PermitRootLogin no
StrictModes yes
AllowUsers
DenyUsers root
DenyGroups root
PasswordAuthentication no
PermitEmptyPasswords no
PubkeyAuthentication yes
MaxAuthTries 1
X11Forwarding no

You may also be interested in DenyHosts if using password authentication for SSH.

Reply
blackMORE Ops June 25, 2014 - 2:23 pm

Hi Tomas,

Below 1024 is usually a port that is registered with IANA for the applications/existing well known services (maybe unused on particular systems). See WikiPedia references here.

If you got a user in your system who can sniff traffic with malicious intentions, then you got bigger problem at hand. A user with sudo access can just enable debug on or turn on plaintext incorrect password logging .. few incorrect password retries and he’s got root password! … Agreed with the rest. PubKeyAuth is possibly second best option with DenyHosts combination (where you login via a VPN or got stationary workstation/static IP etc… etc..) My post was about enabling SSH, not security in general, but I do agree with your notion. Will update it soon. ta.

BTW, keep an eye on my site for my next post that actually addresses exactly what you’ve pointed out. I’m sure you’ll like my new post.

Thanks again for your comment, always appreciate a positive feedback. Cheers,
-BMO

Reply
Tomas June 26, 2014 - 5:01 am

Your statement is only partially correct. We use TCP ports 4 and 12 for SSH – these are unassigned.

When you have >2000 users using your Linux servers, everything happens.

You may find this post useful: https://www.lisenet.com/2013/openssh-server-installation-and-configuration-on-debian/

Reply
Security Jedi July 17, 2014 - 6:53 pm

Great post on how to setup OpenSSH. This allowed me to take it one step further, and set up VNC over SSH.

Reply
blackMORE Ops July 23, 2014 - 12:24 am

Thanks SJ.

Reply
7ViceTry October 21, 2015 - 7:29 am

Hello Sec Jedi. Good job setting up the vnc ! can you share the guide with me on how to do this? and can you access this outside of your lan or only in lan ?

Reply
Dan December 25, 2014 - 12:04 am

Excellent tutorial. Well done.

Reply
tahir January 23, 2015 - 11:46 pm

Very Nice tutorial sir, I just need to ask you that, after applying all these steps, i can access ssh-server through lan, But this is not working on internet, What might be the reason?

Reply
blackMORE Ops January 24, 2015 - 2:33 am

Your router blocking it. Either open port or setup port forwarding.

Reply
heisenberg March 3, 2015 - 7:19 am

When I run ssh root@localhost it just leaves me with a blinking cursor but no prompt. Root log in is enabled in sshd_config. Any thoughts?

Reply
blackMORE Ops March 6, 2015 - 10:11 pm

Hi heisenberg,
Did you restart ssh service?

Reply
1.10 April 11, 2015 - 11:02 am

Hi, Step 3 doesn’t need to be completed. I’ve compared the SSH Keys on two different installs of Kali1.10 and they have different keys by default.

Reply
blackMORE Ops April 11, 2015 - 12:50 pm

Thanks for letting me know. It wasn’t the case when I wrote this article. Instead of removing step 3, I’ll mark it as optional. In that way, readers can make an informed decision. Thanks again.

Reply
Athini Bashe April 20, 2015 - 5:09 pm

Thank you for the tutorial, its so educating now my question is, how can I use my android app with Kali Linux remote SSH. I’m aware of the apps that I can download, i’m in the process of developing my own.

Reply
Johnnycakes581 May 13, 2015 - 1:10 pm

I am trying to access my own SSH server by doing
ssh root@localhost
then it comes up with
root@localhost’s password:
Where would you get this password?

Reply
E. de Klerk October 28, 2015 - 12:19 am

You need to know your root password, on a default install of kali it is set to ‘toor’ but this is the first thing you should have changed.

Reply
MrSys May 20, 2017 - 9:52 pm

I type my root password but it says permission denied anyway

Reply
Joe Schmoe February 1, 2018 - 10:15 am

You have to enable root login in the sshd_config file.

Generally not a good idea unless you have a reason.

Reply
Kash August 27, 2015 - 9:51 pm

Great article! Thank you for the time you took to put this together!

Reply
Vidya Sagar September 20, 2015 - 2:00 pm

See below output:

root@kali2:~# service ssh status
● ssh.service – OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled)
Active: inactive (dead)
root@kali2:~#

I Want to start this service automatically whenever I boot my system. Let me know how to do that.

At present I am manually starting the service.

Reply
rametux (@rametux) April 19, 2016 - 8:08 pm

I got same problem here too. Even after following Step 2, it didn’t work. Anyone?

Reply
fr2632 November 4, 2015 - 10:57 pm

Great tutorial!
The only problem for me is that after root@localhost and after the password it says : Permission denied, please try again…

Reply
fr2632 November 4, 2015 - 11:16 pm

Solved, I changed

PermitRootLogin without-password

with

PermitRootLogin yes

In /etc/ssh/sshd_config

Reply
fr2632 November 4, 2015 - 11:15 pm

Solved, I changed

PermitRootLogin without-password

with

PermitRootLogin yes

In /etc/ssh/sshd_config

Reply
Crudy November 11, 2015 - 1:47 am

Hey guys i hope you respond me , i have some problemes using kali 2 ,
for any link i make is not shared with my local state any link i make ( with a real kali ip 192.168.1.xx) it works only in the kali and is not shared to other wifi’s users i tried many methodes but they didnt work i hope will help me and thank you !

Reply
add or update your tutorials to modern day 2.0 November 13, 2015 - 10:50 am

well make a new one for 2.0. you need to update alot of your old very good tutorials for previous versions, now you have nothing for 2.0. killing us.

Reply
phoenix6142 May 13, 2016 - 12:38 pm

This was a great help, thank you.

Reply
Cristian September 24, 2016 - 4:19 am

Hello, is it possible, that we must also open the ssh port in kali’s firewall?

Reply
mikee531 February 27, 2017 - 3:51 am

i got a problem here. i started the ssh server in linux kali.but when i try to connect from windows using putty i am asked username and passworsd. what xactly are the username and password ? i tried my linux usernmae and passwd but i got access denied. should i configure linux to allow windows??

Reply
DRAGROOT April 12, 2018 - 11:35 am

Install openssh in Android terminal
https://youtu.be/mh6Ldvn__H4

Reply
james1052 October 3, 2018 - 6:35 am

I can confirm that on Kali Linux 2018.3a on the AWS Marketplace, the SSH keys are unique to each provisioned instance.

Reply
1 2

Leave your solution or comment to help others. Comment don't need registration or real email, so feel free.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About Us

blackMORE Ops - touch-icon-72x72

blackMORE Ops” does not promote, encourages and excite hackers, its purpose is to make people aware that what is going around. Know Hacking but No Hacking!

Feature Posts

Newsletter