Search This Blog

Thursday, July 13, 2017

unable to ssh as root without password

sed -i -e 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config

sed -i -e 's/#PermitEmptyPasswords no/PermitEmptyPasswords yes/' /etc/ssh/sshd_config

systemctl restart sshd

1. change the "#PermitRootLogin prohibit-password" to "PermitRootLogin yes"

- This means changing the default behavior of not allowing the Root login (only with)  -> allowing the root login

more info

 * The default for the sshd_config(5) PermitRootLogin option has
   changed from "yes" to "prohibit-password".

 * PermitRootLogin=without-password/prohibit-password now bans all
   interactive authentication methods, allowing only public-key,
   hostbased and GSSAPI authentication (previously it permitted
   keyboard-interactive and password-less authentication if those
   were enabled).

With that configuration you cannot login in as root with a password. Use keys instead.

2. change "#PermitEmptyPasswords no" to "PermitEmptyPasswords yes" as in your case root does not have any password

3. restart the sshd daemon 

Wednesday, July 12, 2017

restart gui on xubuntu

sudo service lightdm restart

Tuesday, July 4, 2017

using nlog from c# code

using NLog;
using NLog.Targets;
using NLog.Config;
using NLog.Win32.Targets;

            // Create configuration object
             LoggingConfiguration config = new LoggingConfiguration();

            // Create targets and add them to the configuration
             ColoredConsoleTarget consoleTarget = new ColoredConsoleTarget();
             config.AddTarget(“console”, consoleTarget);
             //
             FileTarget fileTarget = new FileTarget();
             config.AddTarget(“file”, fileTarget);

            // Set target properties
             consoleTarget.Layout = “${date:format=HH\\:MM\\:ss}: ${message}”;
             // set the file
             fileTarget.FileName = CxUtil.getDataDir() + “\\log.txt”;
             fileTarget.Layout = “${date:format=HH\\:MM\\:ss}: ${message}”;
             // don’t clutter the hard drive
             fileTarget.deleteOldFileOnStartup = true;

            // Define rules
             LoggingRule rule1 = new LoggingRule(“*”, LogLevel.Debug, consoleTarget);
             config.LoggingRules.Add(rule1);
           
             // Only log to file in non-debug mode
             #if !DEBUG
                 LoggingRule rule2 = new LoggingRule(“*”, LogLevel.Debug, fileTarget);
                 config.LoggingRules.Add(rule2);
             #endif

            // Activate the configuration
             LogManager.Configuration = config;

            // Create logger
             Logger logger = LogManager.GetLogger(“Example”);
             // Example usage
             logger.Trace(“trace log message”);
             logger.Debug(“debug log message”);
             logger.Info(“info log message”);
             logger.Warn(“warn log message”);
             logger.Error(“error log message”);
             logger.Fatal(“fatal log message”);