Change log time format of OpenSSH - openssh

OpenSSH log in my system are spitting log in following format.
Aug 21 14:34:44 systemHostName sshd[1952]: Server listening on 0.0.0.0 port 22.
I need to get the year also, in the log time. something like following
2012 Aug 21 14:34:44 systemHostName sshd[1952]: Server listening on 0.0.0.0 port 22.
I tried to look into sshd_config and other web resources but could not find anything useful.
Anybody know, how to change openSSH log time format?

It is syslog, not sshd time format, depends on your syslog implementation, though I haven't seen anyone using the year there.

Related

Unable to Retrieve Directory Using ProFTPD(WHM)

Well, after looking for many solutions. I came here now.
I am setting up WHM/cPanel for hosting website. Everything was going smooth but I am stuck on FTP connection (Server sent passive reply with unroutable address. Using server address instead.)
Server Details:
CentOS Linux release 7.2.1511 (Core)
WHM/cPanel Version 11.58.0.13
FTP Server: PureFTPD
Acutal error while connecting
To fix this issue and get FTP working you need to open up more numbered ports so FTP can connect. I assume you are using CSF.
Login to WHM then go to CSF >> Firewall Configuration >>
allow TCP_In 30000:50000 and TCP_Out 30000:50000
Once you made the changes Restart the firewall
Now you need to make changes in FTP config file to use these ports, you will find this file to this location /etc/pure-ftpd.conf
Now you will see a line as follows and you will need to uncomment it
# Port range for passive connections replies. - for firewalling.
PassivePortRange 30000 50000
Restart FTP Service and should work.

Jenkins - Mail configuration for Hotmail

I don't know what am I doing wrong, I'm searching the net for hours. Anyways, here is my e-mail setup for Jenkins. I'm not able to send any mails. When I click "Test Configuration", I get the following error.
I changed the STMP Port to 25 and still get the same error.
And btw I typed telnet smtp.live.com 587 to my console ant the output was:
Trying 65.55.163.152...
Connected to smtp.glbdns2.microsoft.com.
Escape character is '^]'.
220 BLU437-SMTP76.smtp.hotmail.com Microsoft ESMTP MAIL Service, Version: 8.0.9200.16384 ready at Thu, 2 Jul 2015 04:31:09 -0700
Connection closed by foreign host.
What am I missing? What is the correct configuration? Thanks in advance!
The traceback looks awfully similar to the one in the Jenkins SMTP TSL question, some of those answers might help.
The bounty doesn't allow flagging as duplicate...
The solution on gmail:
Set SMTP server as smtp.gmail.com and port as 25
This should work.

SSH/Kerberos not working on OSX

So I have tried and tried to get my ssh to work with kerberos on Mavericks to no avail. Here are my versions:
ssh: OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
kerberos: Heimdal 1.5.1apple1
I also tried the built in ssh with no effect as well. Here is my config:
ForwardAgent yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials yes
GSSAPIKeyExchange yes
i have checked, there are no overriding settings in my user config
After all of this, I still get prompted for a password when ssh'ing to a linux host that does work with linux clients. (I am able to successfully kinit and i do get a ticket)
Any clues what I am missing? Has anyone has this problem before.
HERE is a link to the ssh connection log. It just seems to abandon gssapi without even trying it... why????
NOTE ON OSX SIERRA:
It appears that Apple broke it again.... The gssapitrusdns stuff is actually a third-party contribution and Apple revved to a newer ssh that doesn't include those patches... See HERE and HERE
ORIGINAL ANSWER (pre Sierra):
Ok, so after even more head-scratching, giving up, and violent attempts to strangle my computer with a power cord, I have found the answer... Turns out, OSX need to be told to explicitly trust DNS.... Add the following line to your ssh config:
GSSAPITrustDNS yes
Source (check the 'Problems and Workarounds' section)
From the logs it looks like server is sending "gssapi-keyex,gssapi-with-mic" methods but somehow client doesn't have support for it.
Look at this logs
preferred publickey,keyboard-interactive,password
can you check your client whether it supports it or not ?
you can check client config file /user//.ssh/config -> on linux system.

can I connect bash to an existing mongod process?

I run two mongo databases on my dev machine. The first runs on the standard port and (apparently) runs at startup. The second I start up as part of my "kickoff the dev env" script. How can I get the output from the first database in bash? I'm talking about the output that looks like:
Wed Oct 30 16:28:27.035 [initandlisten] recover : no journal files present, no recovery needed
Wed Oct 30 16:28:27.215 [initandlisten] waiting for connections on port XX987
Wed Oct 30 16:28:27.216 [websvr] admin web console waiting for connections on port XX987
Wed Oct 30 16:28:34.054 [initandlisten] connection accepted from 127.0.0.1:53736 #1 (1 connection now open)
Wed Oct 30 16:28:34.060 [conn1] end connection 127.0.0.1:53736 (0 connections now open)
Wed Oct 30 16:28:34.061 [initandlisten] connection accepted from 127.0.0.1:53737 #2 (1 connection now open)
Is this called a listening socket? How can I connect to this output from bash?
It looks like you are showing the output of the mongodb log file. In order to separate the log messages of the different mongo processes you'll need to configure separate log file locations for both mongo processes. Then you can just:
tail -f /path/to/mongo_dev/logfile
You can change the log file location of a mongodb process by setting
logpath=/path/to/anyhwere.log
in it's config file. Then restart the mongodb process.

MongoDB running but can't connect using shell

CentOS 5.x Linux with MongoDB 2.0.1 (tried main and legacy-static)
MongoDB is running:
root 31664 1.5 1.4 81848 11148 ? Sl 18:40 0:00 ./mongod -f mongo.conf -vvvvv --fork
Using a simple shell connect to get to the server fails:
[root#xxxx bin]# ./mongo
MongoDB shell version: 2.0.1
connecting to: test
Mon Oct 31 18:41:32 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
The web interface on port 28017 loads fine, as does using the MongoDB shell from a remote Linux host. Can also telnet to localhost:27017, which means no ports are blocked. There is no SELinux running on this machine as well. I have also tried explicitly specifying localhost:2017/db to no avail.
$ ./mongo remote-ip:27017
MongoDB shell version: 2.0.1
connecting to: remote-ip:27017/test
> show dbs
local 0.03125GB
>
Logs are completely mum on the subject:
.....
Mon Oct 31 18:40:34 [initandlisten] fd limit hard:1024 soft:1024 max conn: 819
Mon Oct 31 18:40:34 [initandlisten] waiting for connections on port 27017
Mon Oct 31 18:40:34 BackgroundJob starting: snapshot
Mon Oct 31 18:40:34 BackgroundJob starting: ClientCursorMonitor
Mon Oct 31 18:40:34 BackgroundJob starting: PeriodicTask::Runner
Mon Oct 31 18:40:34 [websvr] fd limit hard:1024 soft:1024 max conn: 819
Mon Oct 31 18:40:34 [websvr] admin web console waiting for connections on port 28017
Stracing the mongo shell client shows only one problematic call:
[pid 31708] connect(4, {sa_family=AF_INET, sin_port=htons(27017), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EBADF (Bad file descriptor)
Filesystem is clean, no ulimit restrictions (running as root for testing). I can see from the strace that the mongo client is trying to connect via TCP (AF_INET), but since it is local and MongoDB creates a file socket, is there a way to tell the client to connect through that instead? Or better yet, why would the client be throwing a EBADF?
EDIT: My basic Mongo conf:
dbpath=/root/mongodb-linux-i686-2.0.1/data
logpath=/root/mongodb-linux-i686-2.0.1/logs/mongo.log
slowms=15
rest=1
I think there is some default config what is missing in this version of mongoDb client. Try to run:
mongo 127.0.0.1:27017
It's strange, but then I've experienced the issue went away :) (so the simple command 'mongo' w/o any params started to work again for me)
[Ubuntu Linux 11.10 x64 / MongoDB 2.0.1]
You may want to check your config to see if the bind_ip is set
bind_ip: 127.0.0.1
If it is then this permits only local logins. Comment this out and restart mongo, this may help.
I had a similar problem, well actually the same (mongo process is running but can't connect to it).
What I did was went to my database path and removed mongod.lock, and then gave it another try (restarted mongo). After that it worked.
Hope it works for you too.
mongodb repair on ubuntu
I had same problem. In my case MongoDB server wasn't running.
Try to open this in your web browser:
http://localhost:28017
If you can't, this means that you have to start MongoDB server.
Run mongod in another terminal tab.
Then in your main tab run mongo which is is the shell that connects to your MongoDB server.
Delete /var/lib/mongodb/mongod.lock, then issue sudo service mongodb start, then mongo.
Open the file /etc/mongod.conf and add the ip of the machine from where you are connecting, to bind_ip
bind_ip = 127.0.0.1,your Remote Machine Ip Address Here
Ex:-
bind_ip = 127.0.0.1,192.168.1.5
Restart mongodb service:
sudo service mongod restart
Make sure mongodb port is opened in the firewall.
You can also comment the line, if you are not worried about security.
I had this problem as well. Is your MongoDB journaling?
I noticed the following "preallocate" entries in the log file.
Once I saw the last line "waiting for connections on port", I could connect.
Notice that this "faster" mode took 12 minutes to intialize.
William
Tue Apr 17 16:48:01 [initandlisten] MongoDB starting : pid=2248 port=27017 dbpath=E:\MongoData 64-bit host=ME
Tue Apr 17 16:48:01 [initandlisten] db version v2.0.0-rc0, pdfile version 4.5
Tue Apr 17 16:48:01 [initandlisten] git version: 8d4bf50111352cee5a4f1abf25b63442d6c45dc4
Tue Apr 17 16:48:01 [initandlisten] build info: windows (6, 1, 7601, 2, 'Service Pack 1') BOOST_LIB_VERSION=1_42
Tue Apr 17 16:48:01 [initandlisten] options: { bind_ip: "ip", dbpath: "E:\MongoData", directoryperdb: true, journal: true, logpath: "E:\MongoData\mongo.log", quiet: true, rest: true, service: true }
Tue Apr 17 16:48:01 [initandlisten] journal dir=E:/MongoData/journal
Tue Apr 17 16:48:01 [initandlisten] recover : no journal files present, no recovery needed
Tue Apr 17 16:48:02 [initandlisten] preallocateIsFaster=true 9.68
Tue Apr 17 16:48:04 [initandlisten] preallocateIsFaster=true 8.44
Tue Apr 17 16:48:06 [initandlisten] preallocateIsFaster=true 9.68
Tue Apr 17 16:48:06 [initandlisten] preallocateIsFaster check took 4.921 secs
Tue Apr 17 16:48:06 [initandlisten] preallocating a journal file E:/MongoData/journal/prealloc.0
Tue Apr 17 16:52:37 [initandlisten] preallocating a journal file E:/MongoData/journal/prealloc.1
Tue Apr 17 16:56:54 [initandlisten] preallocating a journal file E:/MongoData/journal/prealloc.2
Tue Apr 17 17:01:42 [initandlisten] waiting for connections on port 27017
Tue Apr 17 17:01:42 [websvr] admin web console waiting for connections on port 28017
By default, mongodb is configured to listen only to localhost. Excerpt from mongodb default config file :
# Listen to local interface only. Comment out to listen on all interfaces.
bind_ip=127.0.0.1
One needs to comment the bind_ip to listen from external entities.
You wont be able to add shards unless you start listening on non-local interfaces.
HTH,
Abhay Dandekar
This is actually not an error... What happens here is that Mongo relies on a daemon in order to run the local database server, so in order to "fire up" the mongo server in your shell, you have to start the mongo service first.
For Fedora Linux (wich is the Distro I use) You have to run these commands:
1 sudo service mongod start
2 mongo
And there you have it! the server is going to run. Now, If you want Mongo service
to Start when the system boots then you have to run:
sudo chkconfig --levels 235 mongod on
And that's all! If you do that, now in the shell you just have to type mongo in order
to start the server but that's pretty much it, the problem is you have to start the SERVICE first and then the SERVER :)
P.S. The commands I posted might work on other linux distros as well, not just in fedora... In case not maybe you have to tweak some words depending on the distro you're using ;)
Facing the same issue with the error described by Garrett above.
1. MongoDB Server with journaling enabled is running as seen using ps command
2. Mongo client or Mongoose driver are unable to connect to the database.
Solution :
1. Deleting the Mongo.lock file seems to bring life back to normal on the CentOS server.
2. We are fairly new in running MongoDB in production and have been seeing the same issue cropping up a couple of times a week.
3. We've setup a cron schedule to regularly cleanup the lock file and intimate the admin that an incident has occurred.
Searching for a bug fix to this issue or any other more permanent way to resolve it.
If your bind_ip is set to anything other than 127.0.0.1 then you'll need to add the ip explicitly even from the local machine. So simply use the same method that you're using on the remote box on the local box. At least that's what did it for me.
Not so much an answer but more of an FYI:I've just hit this and found this question as a result of searching. Here is the details of my experience:
Shell error
markdsievers#ip-xx-xx-xx-xx:~$ mongo
MongoDB shell version: 2.0.1
connecting to: test
Wed Dec 21 03:36:13 Socket recv() errno:104 Connection reset by peer 127.0.0.1:27017
Wed Dec 21 03:36:13 SocketException: remote: 127.0.0.1:27017 error: 9001 socket exception [1] server [127.0.0.1:27017]
Wed Dec 21 03:36:13 DBClientCursor::init call() failed
Wed Dec 21 03:36:13 Error: Error during mongo startup. :: caused by :: DBClientBase::findN: transport error: 127.0.0.1 query: { whatsmyuri: 1 } shell/mongo.js:84
exception: connect failed
Mongo logs reveal
Wed Dec 21 03:35:04 [initandlisten] connection accepted from 127.0.0.1:50273 #6612
Wed Dec 21 03:35:04 [initandlisten] connection refused because too many open connections: 819
This perhaps indicates the other answer (JaKi) was experiencing the same thing, where some connections were purged and access made possible again for the shell (other clients)
I don't see this having an accepted answer yet, so I'll just add my 2 cents.
I had the exact same issue just now. After a while I realized I've locked localhost out in my iptables rules. So, check your firewall.
On Ubuntu:
Wed Jan 27 10:21:32 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
Solution
look for if mongodb is running by following command:
ps -ef | grep mongo
If mongo is not running you get:
vimal 1806 1698 0 10:11 pts/0 00:00:00 grep --color=auto mongo
You are seeing that the mongo daemon is not there.
Then start it through configuration file(with root priev):
root#vimal:/data# mongod --config /etc/mongodb.conf &
[1] 2131
root#vimal:/data# all output going to: /var/log/mongodb/mongodb.log
you can see the other details:
root#vimal:~# more /etc/mongodb.conf
Open a new terminal to see the result of mongod --config /etc/mongodb.conf &
then type mongo. It should be running or grep
root#vimal:/data# ps -ef | grep mongo
root 3153 1 2 11:39 ? 00:00:23 mongod --config /etc/mongodb.conf
root 3772 3489 0 11:55 pts/1 00:00:00 grep --color=auto mongo
NOW
root#vimal:/data# mongo
MongoDB shell version: 2.0.4
connecting to: test
you get the mongoDB shell
This is not the end of story. I will post the repair method so that it starts automatically every time, most development machine shutdowns every day and the VM must have mongo started automatically at next boot.
After starting the mongod
$mongod --dbpath <db name>
to get shell
$mongo --shell
If your mongoDB server(remote server)'s version is greater then 4.0.3, then you will face this issue. Hence you should replace your current mongo-client shell with below mongo :
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
Then you mongo client will be able to connect your remove mongodb
If you are getting the following message
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.84" (uid=1000 pid=3215 comm="start mongodb ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
shriprasad#shriprasad-HP-430-Notebook-PC:/var/lib/mongodb$ mongo
You must be trying to start the mongodb service as user other than root. You must be root user. Thus log in as root and then run following command as follows:
sudo bash
followed by
service mongodb start

Resources