Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm setting up an SSH server on my home computer. I'm kind of a Linux noob (I've been using Ubuntu since Febuary or so, meaning I'm not terribly good at everything, but I know some basic stuff to try.
So, if I try to connect to the server through my laptop (also running Ubuntu 12.04), I get this error:
Code:
$ ssh 192.168.1.7 -vvv
OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug3: cipher ok: aes128-ctr [aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc]
debug3: cipher ok: aes192-ctr [aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc]
debug3: cipher ok: aes256-ctr [aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc]
debug3: cipher ok: arcfour256 [aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc]
debug3: cipher ok: arcfour128 [aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc]
debug3: cipher ok: aes128-cbc [aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc]
debug3: cipher ok: 3des-cbc [aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc]
debug3: ciphers ok: [aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc]
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.168.1.7 [192.168.1.7] port 22.
debug1: connect to address 192.168.1.7 port 22: Connection refused
ssh: connect to host 192.168.1.7 port 22: Connection refused
If I connect to it through itself (localhost), I get this:
Code:
$ ssh localhost -vvv
OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: connect to address 127.0.0.1 port 22: Connection refused
ssh: connect to host localhost port 22: Connection refused
It is proof that it is not running. You see "00:00:00 grep ....." on output? - it means that "grep" with some options is running, you piped it in last command. So check if you have server installed - it is in package "openssh-server" or just "ssh".
Ok well there are two ssh config files.. ssh_config is the [I]client/I] configuration file and your sshd_config is the daemon or server configuration file. So ssh is running but your looking at a connectivity issue.
Take a look and see if your server is listening on port 22:
Code:
netstat -anp | grep :22
Verify that sshd is running, run the following as root:
Code:
ps aux | grep sshd | grep root | grep -v "grep"
# You should see something like /usr/sbin/sshd for the process.
# If you see other processes or just a single process as "sshd: username" that is an established ssh session
/etc/init.d/sshd status
Let us know what the results of that are before you go much more deeper. The next steps would be to review your sshd_config file and take a look at firewall rules
It is proof that it is not running. You see "00:00:00 grep ....." on output? - it means that "grep" with some options is running, you piped it in last command. So check if you have server installed - it is in package "openssh-server" or just "ssh".
You should check with the /etc/init.d/ script as it has the best functionality built in to check. The ps command should give the /usr/sbin/sshd process running but the init script would confirm that it is not running.
I agree with Arclinux, is SSHD installed? What do you get if you enter:
Code:
sudo ssh status
If you don't see it running, try
Code:
sudo ssh start
You will probably find that it is either not installed or you have an error in your configuration file that keeps it from starting. If you get an error indicating the latter, looking in /var/log/syslog should give you the error line/location to debug it.
It is proof that it is not running. You see "00:00:00 grep ....." on output? - it means that "grep" with some options is running, you piped it in last command. So check if you have server installed - it is in package "openssh-server" or just "ssh".
I definitly have it installed. I've looked in the configs. Also, I was able to connect to it before, but then it stopped working.
Quote:
Ok well there are two ssh config files.. ssh_config is the [I]client/I] configuration file and your sshd_config is the daemon or server configuration file. So ssh is running but your looking at a connectivity issue.
Take a look and see if your server is listening on port 22:
Code:
netstat -anp | grep :22
Verify that sshd is running, run the following as root:
Code:
ps aux | grep sshd | grep root | grep -v "grep"
# You should see something like /usr/sbin/sshd for the process.
# If you see other processes or just a single process as "sshd: username" that is an established ssh session
/etc/init.d/sshd status
Let us know what the results of that are before you go much more deeper. The next steps would be to review your sshd_config file and take a look at firewall rules
For the first and second commands, it doesn't return anything. For the third, I get this:
Code:
-bash: /etc/init.d/sshd: No such file or directory
Not completely sure what you mean by your second post. Sorry for my noobishness.
Quote:
Your SSHD (server) is not running. If it were running you would see something like the following:
I agree with Arclinux, is SSHD installed? What do you get if you enter:
Code:
sudo ssh status
If you don't see it running, try
Code:
sudo ssh start
You will probably find that it is either not installed or you have an error in your configuration file that keeps it from starting. If you get an error indicating the latter, looking in /var/log/syslog should give you the error line/location to debug it.
Well, when I run either of the commands you listed, I get this error:
Code:
ssh: Could not resolve hostname stop: Name or service not known
But, if I run it like this, I get the following:
Code:
# start ssh
ssh start/running, process 31905
If I stop it the same way, I get this:
Code:
# stop ssh
stop: Unknown instance:
Thanks again for all of the replies.
Last edited by TechHunter16; 06-28-2012 at 08:10 PM.
There should be a reason why it cannot start at the end. If it start however, then post your /etc/init/ssh.conf and check of existence "/etc/ssh/sshd_not_to_be_run" or "/dev/null" and check "/var/log/syslog" after trying command "start ssh".
ssh: Could not resolve hostname stop: Name or service not known
My bad, I left out a word in the command. It should have been:
Code:
sudo service ssh status and service ssh start
you can also use the full command to the init script:
sudo /etc/init.d/ssh start
Regarding this error:
Code:
-bash: /etc/init.d/sshd: No such file or directory
In Ubuntu the init script is ssh, not sshd. This is distribution specific, for example in Centos it is /etc/init.d/sshd
Okay, first command outputted this:
Code:
status: Env must be KEY=VALUE pairs
For the init scrpit, I get this:
Code:
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service ssh start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start ssh
So, I've basically already done that. I'm assuming that is a distro-specific thing also?
Quote:
Try to start ssh with this command:
Code:
/usr/sbin/sshd -ddd
There should be a reason why it cannot start at the end. If it start however, then post your /etc/init/ssh.conf and check of existence "/etc/ssh/sshd_not_to_be_run" or "/dev/null" and check "/var/log/syslog" after trying command "start ssh".
Okay, so no, it does not run, and by the looks of it, it seems to be bad config.:
The "and" was not meant to be part of the command. In my first post to this thread, I said "sudo ssh status" which should have been sudo service ssh status" and if you didn't see it report a pid indicating that it was running, try "sudo ssh start", which should have been "sudo service ssh start".
In any case, you have confirmed that it is not running and your log files are indicating a problem with your configuration file, which appears to be caused by options you have added.
Quote:
You will have to start it as root for it to bind to port 22.
Correct, but as a point of clarification for your distribution: in order to start your SSH server as root in ubunutu you will need to prefix the command with SUDO (super user do) because Ubuntu disables the 'root' account. The reason is that ports below 1024 are considered privileged and are off limits to normal users. During normal startup this is not a problem as the init scripts, one of which starts SSH, are launched with root permissions.
One other thing to mention, you think it is running, you can verify that the process is active and listening using the netstat command:
Code:
sudo netsat -pane | grep 22
which should give you output with a line like the following:
I believe your server didn't work by these bad configuration options. And next "Permission denied" errors were, because you trying to run server on non root account, as other noticed. Check if it still doesn't start after reboot by ps or netstat. If not then once again show output of "/usr/sbin/sshd -ddd".
By the way these options "ForwardAgent" and "ForwardX11" are for ssh client configuration (/etc/ssh/ssh_config), not server. For server there is "X11Forwarding" option.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.