cygwin sshd service not starting on windows 2003 - ssh

Hi! I get following error when tried to start the Cygwin sshd Windows service:
$ cygrunsrv.exe -S sshd
cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error 1062:
The service has not been started.
I used ssh-host-config to install the service with privilege separation. The script created two users: sshd and sshd_server.

The following solved this issue for me:
Add the "Full Control" permission for the SYSTEM user to the following directories:
C:\Cygwin
C:\Cygwin\var
C:\Cygwin\var\log
If it still doesn't help then, try running ssh-host-config -y and retry cygrunsrv -S sshd.
Also, I actually uninstalled the sshd service by issuing cygrunsrv -R sshd prior to retrying and only after that running ssh-host-config -y.
(I found the solution at http://www.noah.org/wiki/Sshd_on_Windows)

Related

Starting ssh-agent on Windows 10 fails: "unable to start ssh-agent service, error :1058"

When I try to start the ssh-agent on Windows 10 via PowerShell (with elevated right or without) by entering Start-Service ssh-agent I get the error
unable to start ssh-agent service, error :1058
When I check of the service is running via Get-Service ssh-agent is returns that the service is stopped.
How can I get the ssh-agent running?
Yeah, as others have suggested, this error seems to mean that ssh-agent is installed but its service (on windows) hasn't been started.
You can check this by running in Windows PowerShell:
> Get-Service ssh-agent
And then check the output of status is not running.
Status Name DisplayName
------ ---- -----------
Stopped ssh-agent OpenSSH Authentication Agent
Then check that the service has been disabled by running
> Get-Service ssh-agent | Select StartType
StartType
---------
Disabled
I suggest setting the service to start manually. This means that as soon as you run ssh-agent, it'll start the service. You can do this through the Services GUI or you can run the command in admin mode:
> Get-Service -Name ssh-agent | Set-Service -StartupType Manual
Alternatively, you can set it through the GUI if you prefer.
I solved the problem by changing the StartupType of the ssh-agent to Manual via Set-Service ssh-agent -StartupType Manual.
Then I was able to start the service via Start-Service ssh-agent or just ssh-agent.exe.
I get the same error in Cygwin. I had to install the openssh package in Cygwin Setup.
(The strange thing was that all ssh-* commands were valid, (bash could execute as program) but the openssh package wasn't installed.)
Adding here that if you have this problem and run start-ssh-agent in PowerShell it will "switch" to cmd(not powershell) like functionality until you exit the batch job started by your previous command.
If you don't, you can no longer access PowerShell functions and will get errors like: 'Get-Service' is not recognized as an internal or external command, operable program or batch file
To solve this problem follow only a few steps:
1 => open Window Powershell as administrator and write
2 => Get-Service ssh-agent //(you will find status stopped )
3 => Now write in the Powershell
4 => Set-Service ssh-agent -StartupType Manual
you will find status running.. hopefully help to resolve the problem.
This just happens to me because I was running the command in a non-administrator Powershell. Running it with admin powers solved the problem

Chef-client does not work from Workstation but does work directly on the server

I have a chef recipe that runs a chocolatey install for Microsoft SQL server. From my workbench when I run
knife winrm [IP] 'chef-client -o "recipe[NetDevMachine::default]"' -m -x 'domain\myuser'
over a node it fails with the error:
532459699 or sometimes 2022834173 or 2057043966
However if I log onto the VM as the same user and locally run
chef-client -o "recipe[NetDevMachine::default]"
It works. Does anyone know what the difference is between running chef-client locally and running it remotely from the workbench? What does chef-client do differently here? Both are pulling the recipe from the same chef-server repo.
Additional Details
I am using the same user for both
I have successfully run other recipes from the workstation, it's just this MicrosoftSQLServer install that's not working
running "knife winrm [IP] 'choco install MicrosoftSQLServer' -m -x 'domain\myuser' also does not work
Recipe contents:
powershell_script "choco install MicrosoftSQLServer2014" do
code <<-EOH
choco install MicrosoftSQLServer2014
EOH
end
Error:
[ERROR] Running C:\Users\myuser\AppData\Local\Temp\MicrosoftSQLServer2014\setup.exe with
/QUIET /IACCEPTSQLSERVERLICENSETERMS /ACTION=INSTALL /INSTANCENAME=MSSQLSERVER /FEATURES=SQL,TOOLS,LOCALDB
/SQLSVCACCOUNT="NT AUTHORITY\Network Service" /SQLSYSADMINACCOUNTS=BUILTIN\ADMINISTRATORS
/SKIPRULES=REBOOTREQUIREDCHECK UIMODE=AUTOADVANCE was not successful.
Exit code was '-532459699'.
Edit - the only difference I can see is that one runs in the foreground and the other doesn't. So the location of the compile chef-script is /temp/2 for the failing run. I don't know if there is a way to force chef to run in the foreground or if that will even help.
Thanks
I never got to the bottom of this and still don't understand how running the chef client remotely using knife was different from running chef client directly on the VM. Perhaps it was something to do with the handling of credentials or permissions when remotely sending commands.
But I did find that removing chocolatey and replacing it a command line silent install inside a chef powershell resource allowed me to install MSSQL.

Can't add Apache to start at boot with chkconfig (opensuse 13.1)

I'm running opensuse 13.1, and I installed Apache2 as part of LAMP.
Apache2 works just fine, except I can't make it start automatically with boot.
I used "chkconfig -a apache2" command (as described here)
which gives an error "apache2: unknown service".
Appreciate any hints.
Apache2 has been migrated to systemd. chkconfig works only for SysV services.
The following command (apparently) worked for me:
systemctl enable apache2.service
It seems that the OpenSUSE doc is out of sync.
Find the name of the service:
ls -al /etc/init.d/
(Look for apache or httpd)
Then use that name in chkconfig.

Error with rabbit-mq server

I am trying to setup OpenStack on Ubuntu 12.04 using devstack. Now, the error I am getting is:
Setting up rabbitmq-server (2.7.1-0ubuntu4) ...
Starting rabbitmq-server: FAILED - check /var/log/rabbitmq/startup_{log, _err}
rabbitmq-server.
invoke-rc.d: initscript rabbitmq-server, action "start" failed.
dpkg: error processing rabbitmq-server (--configure):
subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
rabbitmq-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
++ err_trap
++ local r=100
++ set +o xtrace
stack.sh failed
Any idea why am I getting this error?
I had this issue twice, when either hostname or ip address in the hosts file didn't match.
Therefore, check that you provide the correct ip address and hostname in the /etc/hosts file
Run sudo cat /etc/hostname to see your hostname
Output:
yoursite
Run sudo nano /etc/hosts
File contains:
127.0.0.1 yoursite
As you see from cat /etc/hostname, hostname is the same as in the /etc/hosts:
Run sudo rabbitmq-server start to start the rabbitmq-server
Try deleting the folder /var/lib/rabbitmq and re-running ./stack.sh
If that doesn't work either, run the following after stach.sh fails:
chown -R rabbitmq:rabbitmq /var/lib/rabbitmq
chown -R rabbitmq:rabbitmq /var/log/rabbitmq
service rabbitmq-server restart
and check the status of rabbitmq using "rabbitmqctl status"
Similar thing happen to me. Rabbit depends on being able to resolve a hostname, run this:
echo "127.0.0.1 $(hostname -s)" | sudo tee -a /etc/hosts
This way works for me.
First go to
sudo vim /etc/hosts
and set
127.0.0.1 <hostname>
then open firewall
sudo rabbitmq-plugins enable rabbitmq_management
sudo service rabbitmq-server restart
For a clean environment, this will not happen. You must run devstack for several times, and one of them failed but you didn't get it cleaned.
run command pf -ef | grep rabbitmq, kill all rabbitmq processes. then it would be fine to run ./stack.sh
it is highly recommended to run ./unstack.sh && ./clean.sh before ./stack.sh
Just to be sure, take a look to your local network
ip add
If there's no lo network, then you should enable it:
ifconfig lo up
Then restart the server again and let's see if it works again now
systemctl start rabbitmq-server
I had the same problem though my /etc/hosts and DNS were OK. I suspect that SystemV init script was started too early when the network was not ready yet. I rewrote the startup script to systemd on CentOS 7.8 and it seems to work well now.
[Unit]
Description=RabbitMQ
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
RuntimeDirectory=rabbitmq
PrivateTmp=true
Restart=on-failure
RestartSec=10
WorkingDirectory=/opt/data/rabbitmq/
User=rabbitmq
Group=rabbitmq
ExecStart=/opt/app/rabbitmq/default/sbin/rabbitmq-server
ExecStop=/opt/app/rabbitmq/default/sbin/rabbitmqctl stop
ExecStop=/bin/sh -c "while ps -p $MAINPID >/dev/null 2>&1; do sleep 1; done"
StandardOutput=journal
StandardError=inherit
[Install]
WantedBy=multi-user.target

How do I stop the RabbitMQ server on localhost

I installed RabbitMQ server on OS X, and started it on command line. Now, it is not obvious that how I should stop it from running? After I did:
sudo rabbitmq-server -detached
I get:
Activating RabbitMQ plugins ...
0 plugins activated:
That was it. How should I properly shut it down? In the document, it mentions using rabbitmqctl(1), but it's not clear to me what that means. Thanks.
Edit: As per comment below, this is what I get for running sudo rabbitmqctl stop:
(project_env)mlstr-1:Package mlstr$ sudo rabbitmqctl stop
Password:
Stopping and halting node rabbit#h002 ...
Error: unable to connect to node rabbit#h002: nodedown
DIAGNOSTICS
===========
nodes in question: [rabbit#h002]
hosts, their running nodes and ports:
- h002: [{rabbit,62428},{rabbitmqctl7069,64735}]
current node details:
- node name: rabbitmqctl7069#h002
- home dir: /opt/local/var/lib/rabbitmq
- cookie hash: q7VU0JjCd0VG7jOEF9Hf/g==
Why is there still a 'current node'? I have not run any client program but only the RabbitMQ server, does that mean a server is still running?
It turns out that it is related to permissions. Somehow my rabbitmq server was started with user 'rabbitmq' (which is strange), so that I had to do
sudo -u rabbitmq rabbitmqctl stop
In my dev environment where I keep it running all the time, I use:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.rabbitmq.plist
and to start it
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.rabbitmq.plist
Even easier....
brew services stop rabbitmq
brew services start rabbitmq
Use rabbitmqctl stop to stop any node. If you need to specify the node giving you trouble, add the -n rabbit#[hostname] option.
You can also use the shortcut RabbitMQ Service - stop if you don't like the commands
stop
sudo systemctl stop rabbitmq-server
start
sudo systemctl start rabbitmq-server
For Windows, use PowerShell as Admin, then run
.\rabbitmq-service.bat stop
stop Stop the service. The service must be running for this command to have any effect.
https://www.rabbitmq.com/man/rabbitmq-service.8.html
For OP's answer above,
It turns out that it is related to permissions.
I have no knowledge on this.
For mac users
To Stop
brew services stop rabbitmq
To Start
brew services start rabbitmq
To Restart
brew services restart rabbitmq
To Know the status of the server
brew services info rabbitmq