6

I'm following this tutorial.

In the section on installing ssh in 16.04 I did:

sudo apt-get install ssh

I tested ssh with:

which ssh

It gave me a path indicating that it's working.

But when I tried:

which sshd

Nothing was produced. No file location no errors nothing?

How can I fix the sshd install?


EDIT:

In answer to steeldriver:

$ echo $path 
/home/hugh/.sdkman/candidates/java/current/bin:/home/hugh/anaconda3/bin:~/anaconda/bin:~/anaconda/bin:~/anaconda/bin:/home/hugh/bin:/home/hugh/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

$ dpkg -L openssh-server
dpkg-query: package 'openssh-server' is not installed  
Use dpkg --info (= dpkg-deb --info) to examine archive files,  
and dpkg --contents (= dpkg-deb --contents) to list their contents.

I should probably mention that I am running all this on a stand alone machine I don't currently have access to a server. Could that explain the problem?

8
  • 1
    Run sudo service ssh restart and see if you can SSH into it Dec 19, 2017 at 18:15
  • 1
    Remember which only searches the current user's path - for a non-privileged user, that might not include /usr/sbin Dec 19, 2017 at 18:18
  • I just tried that and I got the following error "Failed to restart ssh.service: Unit ssh.service not found."
    – Bazman
    Dec 19, 2017 at 18:18
  • @steeldriver so how can I search correctly
    – Bazman
    Dec 19, 2017 at 18:21
  • 1
    More specifically, ssh is a metapackage that should install both openssh-client and openssh-server Dec 19, 2017 at 18:22

2 Answers 2

5

The best way to make this work is to install openssh-client package ( with the client tools) and the openssh-server package (with the server daemon):

sudo apt-get install openssh-client openssh-server

That should solve your problem.

2
  • Installing the ssh package already does this. The problem here is most likely that the SSH server is already running but the OP is just not seeing it with which. Dec 19, 2017 at 22:54
  • Or maybe not, judging from other comments - see my new comment on question. Dec 19, 2017 at 22:58
0

This is a very late response but it may be valid to some folks.

For anyone who may suffer from the same situation as the question says aka which ssh showing up the location but which sshd not showing anything, this simply means that you only have SSH client and no SSH server running in your machine. You can SSH to other computers but those computers cannot ssh back to you.

I tried to install ssh server through:

sudo apt install openssh-server

When I ran which sshd I still could not get anything. What I did was complete removal of SSH through: (mind you if you copy this command it wont ask you for confirmation as I have used -y confirmation)

sudo apt remove ssh --purge -y

I then re-installed ssh (which adds openssh-client and openssh-server) through:

sudo apt install ssh -y

After re-installing ssh that way, for sanity and assurance I restarted SSH daemon through:

sudo service sshd restart

when I did which ssh, I got a response so did when I issued which sshd. I hope this helps someone else. BTW The Ubuntu 18.04 instance was on VirtualBox on a Windows 10 machine, I wanted to access it from Windows (Yes, I know there is WSL and I use it).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.