I am trying to create a ssh handle through module http://search.cpan.org/~salva/Net-OpenSSH-0.62/. I tried setting GSSAPIAuthentication and GSSAPIDelegateCredentials to "No", but these setting don't take effect if my .ssh/config is like this:
$ cat myusername/.ssh/config
Host *
CheckHostIP no
StrictHostKeyChecking no
HashKnownHosts no
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no
UserKnownHostsFile /dev/null
LogLevel ERROR
This is how I try to set GSSAPIAuthentication and GSSAPIDelegateCredentials. Also is there a way to give -F option in open ssh constructor so that by default ssh uses some other config file rather than using the one user my user name?
$self->{ssh} = Net::OpenSSH->new($host,
user => $username,
passwd => $password,
timeout => $timeout,
default_stderr_discard => 1,
kill_ssh_on_timeout => 1,
master_opts => [-o => "UserKnownHostsFile=/dev/null",
-o => "GSSAPIAuthentication=no",
-o => "GSSAPIDelegateCredentials=no",
-o => "StrictHostKeyChecking=no"]);
Just add -F => 'somepath/config' under master_opts:
master_opts => [-F => 'somepath/config']
and another line like this:
$self->{ssh}->{_ssh_opts} = ['-F', 'somepath/config'];'
Related
I run snmptrapd and can see incoming trap, when send trap via snmptrap
snmptrap -c public -v 2c localhost "" 1.3.3.3.3.3.3.3 1.2.2.2.2.2.2 s "Aliens here"
But I no have trap, when send via Perl script
use SNMP;
$sess = new SNMP::Session(DestHost => '127.0.0.1', RemotePort => "162" );
$sess->trap(enterprise=>'.1.3.6.1.4.1.2021', # or 'ucdavis' [default]
agent => '127.0.0.1', # or 'localhost',[dflt 1st intf on host]
generic => specific, # can be omitted if 'specific' supplied
specific => 5, # can be omitted if 'generic' supplied
uptime => 1234, # dflt to localhost uptime (0 on win32)
[[ifIndex, 1, 1],[sysLocation, 0, "here"]]);
What's wrong?
Your second version i.e. the perl one is not specifying community or version, unlike the first one. Try adding them
$sess = new SNMP::Session(DestHost => '127.0.0.1',
RemotePort => "162",
Community => "public,
Version => 2);
Also see http://www.remothelast.altervista.org/SNMP_Perl.html
and http://www.net-snmp.org/docs/perl-SNMP-README.html for SNMP::Session usage.
I want to run the following setup script to configure a postgresql database that's being deployed via a virtual machine, provisioned via vagrant using puppet:
#!/bin/bash -e
sudo su - postgres
createdb testdb
psql -s tm351test -c "create user test password 'test';GRANT ALL PRIVILEGES ON DATABASE testdb TO test;"
touch /root/postgresql.done
My vagrant config takes the form:
package {
[
'postgresql',
'postgresql-client'
]: ensure => latest;
}
file {
'/root/postgresql.setup':
source => 'puppet:///modules/infinite_interns/root/postgresql.setup',
owner => root,
group => root,
mode => '0744';
}
#TO DO - how do we guarantee the postgresql server is running and tools available?
exec {
'setup-postgresql':
cwd => '/root',
command => '/root/postgresql.setup',
creates => '/root/postgresql.done';
}
service {
'postgresql':
ensure => running,
enable => true;
}
Package['postgresql'] -> Service['postgresql']
How do I guarantee that that the postgresql server is installed and running, and the command line tools available, before running the config script?
I'm new to Puppet - does the Exec() not run if the created file postgresql.done exists?
I suspect that the psql command may also expect a confirmatory "return" to execute the command - how would I do that?
There's an official postgresql module that can be easily installed:
puppet module install puppetlabs-postgresql
or adding following to your Puppetfile:
mod 'puppetlabs-postgresql'
The configuration might look like this:
class { 'postgresql::globals':
encoding => 'UTF-8',
locale => 'en_US.UTF-8',
version => '9.6',
}->
class { 'postgresql::server':
ip_mask_deny_postgres_user => '0.0.0.0/32',
ip_mask_allow_all_users => '0.0.0.0/0',
listen_addresses => '*',
version => '9.6',
}
postgresql::server::db { 'testdb':
user => 'test',
password => postgresql_password('test', 'testpassword'),
}
postgresql::server::pg_hba_rule { 'allow connection from ...':
description => "Open up PostgreSQL for access from test domain",
type => 'host',
database => 'testdb',
user => 'test',
address => '.testdomain.com',
auth_method => 'md5',
}
Your best bet is to use the postgres module https://forge.puppetlabs.com/puppetlabs/postgresql
I have this text in this file:
test.php
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'original',
'username' => 'root',
'password' => 'root',
'host' => 'localhost'
),
),
);
In terminal run this line to replace 'original' with 'new'
sed -i 's/original/new/g' test.php
UPDATE: The error message is:
sed: 1: "test.php": undefined label 'est.php'
What is the problem?
UPDATE 2:
If I just run: ( I removed '-i')
sed 's/original/new/g' test.php
I see the file text modified in the terminal. But then the file is not saved.
On BSDish platforms (including Mac OSX), the -i option requires an argument.
sed -i '' 's/original/new/g' test.php
Notice the empty argument ''.
I'm using Net::OpenSSH module to connect to a node. But while connecting to the node, I need to specify -v for ssh as ssh -v admin#hostname. Tried using master_opts and default_ssh_opts. But they didn't work.
my $ssh = Net::OpenSSH->new("$user_name\:$password\#$server",strict_mode => 0, default_ssh_opts => [-o => "-v"]);
How can this be achieved?
my $ssh = Net::OpenSSH->new($server,
user => $user_name,
password => $password,
strict_mode => 0,
master_opts => ['-v']);
PostgreSQL 8.4 Fails to Start on Ubuntu 10.10
sudo /etc/init.d/postgresql start
* Starting PostgreSQL 8.4 database server
* Error: could not exec /usr/lib/postgresql/8.4/bin/pg_ctl /usr/lib/postgresql/8.4/bin/pg_ctl start -D /var/lib/postgresql/8.4/main -l /var/log/postgresql/postgresql-8.4-main.log -s -o -c config_file="/etc/postgresql/8.4/main/postgresql.conf" :
running ldd on /usr/lib/postgresql/8.4/bin/pg_ctl
ldd /usr/lib/postgresql/8.4/bin/pg_ctl
linux-gate.so.1 => (0xb77e4000)
libpq.so.5 => /usr/lib/libpq.so.5 (0xb77a2000)
libc.so.6 => /lib/libc.so.6 (0xb7645000)
libssl.so.0.9.8 => /lib/libssl.so.0.9.8 (0xb75fb000)
libcrypto.so.0.9.8 => /lib/libcrypto.so.0.9.8 (0xb74ac000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0xb73fd000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0xb73f9000)
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0xb73ca000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0xb7398000)
libldap_r-2.4.so.2 => /usr/lib/libldap_r-2.4.so.2 (0xb7351000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb7337000)
/lib/ld-linux.so.2 (0xb77e5000)
libdl.so.2 => /lib/libdl.so.2 (0xb7333000)
libz.so.1 => /lib/libz.so.1 (0xb731e000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0xb72fa000)
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0xb72f1000)
libkeyutils.so.1 => /lib/libkeyutils.so.1 (0xb72ed000)
libresolv.so.2 => /lib/libresolv.so.2 (0xb72d9000)
liblber-2.4.so.2 => /usr/lib/liblber-2.4.so.2 (0xb72cc000)
libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0xb72b4000)
libgnutls.so.26 => /usr/lib/libgnutls.so.26 (0xb7218000)
libtasn1.so.3 => /usr/lib/libtasn1.so.3 (0xb7207000)
libgcrypt.so.11 => /lib/libgcrypt.so.11 (0xb7193000)
libgpg-error.so.0 => /lib/libgpg-error.so.0 (0xb718e000)
I have checked permissions and have given root appropriate permissions, and I am trying to run postgresql as root.
PostgreSQL refuses to run as root. This is so that bugs in the back-end, plus bugs in functions written in untrusted languages, cannot be used to do arbitrary actions over the whole system. PostgreSQL must run as a relatively limited user, usually the postgres user and the start-up scripts normally enforce this.
Grant permissions to the postgres user rather than root. Then everything should work fine.