5

When doing this check:

$ /usr/sbin/sshd -t

Getting:

Could not load host key: /etc/ssh_host_rsa_key
Could not load host key: /etc/ssh_host_dsa_key

But when doing same check with sudo all is good:

$ sudo /usr/sbin/sshd -t
$

Does anyone know why does this happen, what’s wrong with my standard user and how to fix it?

2
  • When you are getting the error, are you running sshd as root?
    – Kenster
    Commented Feb 21, 2015 at 21:56
  • No as it's posted
    – drew1kun
    Commented Feb 21, 2015 at 22:32

2 Answers 2

6

Does anyone know why does this happen, what’s wrong with my standard user and how to fix it?

There is nothing wrong; you are attempting to run sshd (SSH daemon) as a non-privileged user.

For example, I am on Mac OS X 10.9.5 (Mavericks) and get the same exact “error” when running /usr/sbin/sshd -t:

Could not load host key: /etc/ssh_host_rsa_key
Could not load host key: /etc/ssh_host_dsa_key

Which is to be expected since sshd is the SSH daemon—note the d after ssh—that would run as a SSH server on the system listening and waiting for remote SSH login requests. So it would always need root/sudo permissions to work.

So this is not an “error” but rather expected behavior when attempting to run a system daemon like sshd as a non-privileged user.

Perhaps you are trying to run ssh -t? As the man page for the ssh -t option explains:

Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.

Which basically allows you to run a command remotely from your current terminal and have the output displayed locally as if it ran on your local machine. So—as this page explains—if you wanted to run ls on a remote machine without actually fully logging in you could run this command:

ssh -t [username]@[hostname] ls

The output of ls would show up on your screen and the ssh connection would close immediately after that command completed.

1

You can create the missing keys by running:

/usr/bin/ssh-keygen -A

See also: https://bbs.archlinux.org/viewtopic.php?id=165382

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .