Archive

Archive for the ‘Unix/Linux’ Category

TNSPing & SQLPlus just hang without errors

November 22, 2016 Leave a comment

Usually, when you connect to Oracle, you get errors that give you some feedback on what is happening.

Today, I got an issue where when trying to connect to SQLplus or even running a tnsping command was hanging. Not getting any error to start the troubleshooting. The issue was definitely some sort of connectivity but not able to point it out

In our case, we use “nameserver” in addition to tnsnames.ora. Our sqlnet.ora file looks like this:

NAMES.DIRECTORY_PATH= (ONAMES,TNSNAMES)
I needed to trace my “tnsping” command to see where it is getting hung.

To troubleshoot the issue with tnsping hanging, all you need to do is add these settings in sqlnet.ora to trace tnsping

TNSPING.TRACE_LEVEL = ADMIN
TNSPING.TRACE_DIRECTORY =/d01/abc/product/8.0.6/network/admin

My being a linux box and hence the path. You may need to modify according to your OS and directory

I ran the “tnsping” to the same Oracle SID again, a trace file “tnsping.trc” got generated in the path defined in the above “TNSPING.TRACE_DIRECTORY” variable.

Careful review of the trace file revealed that he connection was having an issue with the “name server” defined in my sqlnet.ora file.
I asked the Oracle DBA to confirm if the “name server” is started and she confirmed that it is not. Once she started the “name server”, tnsping command went successfully and I was able to connect to SQLplus.

Hope this helps you in some way.

Happy learning!!!

-Anand M

PGP key generation using gpg 1.4.5 on Linux

November 15, 2016 Leave a comment

Step 1 – Confirm GPG version


$gpg -help
gpg (GnuPG) 1.4.5
Copyright (C) 2006 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.

Step 2 – Start generating gpg key


$ gpg --gen-key
gpg (GnuPG) 1.4.5; Copyright (C) 2006 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.

Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection? 5
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y

You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"

Real name: <User ID for which the key is being generated>
Email address: <Valid mail ID>
Comment:
You selected this USER-ID:
"<User ID provided earlier> <Mail ID>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.

You don't want a passphrase - this is probably a *bad* idea!
I will do it anyway. You can change your passphrase at any time,
using this program with the option "--edit-key".

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.

Not enough random bytes available. Please do some other work to give
the OS a chance to collect more entropy! (Need 276 more bytes)
....+++++
..+++++
gpg: key 193EAC92 marked as ultimately trusted
public and secret key created and signed.

gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
pub 2048R/193EAC92 2016-11-15
Key fingerprint = F7B1 F82D 8DA3 850B 5F8A 5905 B93D 5AF3 193E AC92
uid <User ID provided earlier> <Mail ID>

Note that this key cannot be used for encryption. You may want to use
the command "--edit-key" to generate a subkey for this purpose.

Step 3 – List your keys


$ gpg -k
/home/.gnupg/pubring.gpg
-----------------------------------------
pub 2048R/193EAC92 2016-11-15
uid <User ID provided earlier> <Mail ID>

Step 4 –  Export the public key in ASCII format


$ gpg --armor --output <User ID>-pub.asc --export '<User ID>'
$
$ ls -ltr
-rw-rw-r-- 1 xxx xxxyy 979 Nov 15 09:28 -pub.asc

$ cat <User ID>-pub.asc
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.5 (GNU/Linux)

mQENBFgrKJYBCADMiFYMrVbhl7HH/WLPqPN5SSSaxv5go92m9LjcLysU0Vd9+JTi
hck+8zy3wutY4Q6QK61Zlx72J/Va+4hcv8tMKaJjWfhEGbXV54yKNjNoSM20BtuO
AC5+Z4/2UWA3xh3S1JPRRiV3KDO0MTM2JdhH9sufkhpBsLdJd+jFq+X8o633hqAk
xK75ihNYyof0Pi8VqGJdmaEwgzy1/bXIYeH8wbivC7yx6Kg84oF5Znii50tP6Grq
JygEcnyVjrfS6frsnO4uIBQEuFFoqLGHBohWKQqwkRU6Sd6KTIFkdN6E/SE1XelF
EDMURzDczxsQYaNH1A5QRLNxAC2Zm+uCt76bABEBAAG0NHN2Y19Xb3JrZGF5X3Nm
dHAgPGFuYW5kLm1hbmRpbHdhci1zY0BhaXJsaXF1aWRlLmNvbT6JATYEEwECACAF
AlgrKJYCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRC5PVrzGT6skkMmB/4m
SxJJ/cgPBcMArpUpsargl/g4SOVuH1RKIBi+Sjqt1n7ioW3zfceUxEz0u3t76KaN
4+ndKrCxxCokL8xOu0Qgq1tQtdl5MiONwJ7hvxa459U7qjDE9joj/4WcnxZVIYhj
5+ZPxdR+dfiFmJDyIkln1wUnB8RmAov/hzNCvx50nmLJUIVM6C+e3VWyDqDx66Uh
vHUPpLY+wk/d+qyHeldk4nqa5z+A6Oh3ZB1qcc9h9mEd3tDHQLZiaiqXst0pFQB+
3X9QiSektAXrKSIuOf7Bky4DjDfpoCWuSDDpTaF1IIUTv3YrosbyRamAJ3fAu39x
ltW8BKpKP3nJWKmWmw7i
=EkgV
-----END PGP PUBLIC KEY BLOCK-----
$

 

Happy reading.

-Anand M

Categories: Unix/Linux Tags: , , ,

How to Generate SSH key in Linux

Some or the other times, there is a need to have a SSH key generated to allow traffic from/to different server. Today I created a SSH key on LINUX machine.

You need to run the command “ssh-keygen -t dsa” on the command prompt.

applerp.R12VIS.adc-al-lnx45>ssh-keygen -t dsa
Generating public/private dsa key pair

Enter file in which to save the key (/home/applerp/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/applerp/.ssh/id_dsa.
Your public key has been saved in /home/applerp/.ssh/id_dsa.pub.
The key fingerprint is:
48:80:4f:8f:0a:7b:27:e4:82:a0:33:ab:89:48:67:ed <a href="mailto:applerp@adc-al-lnx45.am.corp.airliquide.com">applerp@adc-al-lnx45.am.corp.airliquide.com</a>
<em>applerp.R12VIS.adc-al-lnx45></em>

If you need to create 4k RSA SSH key, issue the below command
ssh-keygen -t rsa -b 4096

And once the key is generated, if you would like to view the fingerprint, issue below command
ssh-keygen -lf <complete_path_of_public_key>/id_rsa.pub
-Anand

Categories: Unix/Linux

Passwordless SSH login

Many times requirement comes from development team that they need to login to remote server for some activity – be it ‘ftp’ or ‘copy’ or ‘writing’ on the remote server. In such cases, it is required that there is seamless and password less login from source server to target server.

I am going to discuss the way to achieve the same…
First of all be clear on

  1. what is the user on source server. say e.g. on application tier it is ‘applmgr’ and source server is A
  2. what is the user on target server – user could be same of different on target server. For my case, i would consider it to be different i.e. ‘wlshop’ and server is B

Step 1: Login to source server A using ‘applmgr’ user

Step 2: Generate public/private key pair using ssh-keygen command. This will prompt you to save the key in the default directory (/home/applmgr/.ssh/id_rsa). It will ask yo put the passsphrase. You may or may not enter the same

Step 3: Now the identification key is saved in /home/applmgr/.ssh/id_rsa and public key is saved in /home/applmgr/.ssh/id_rsa.pub

Step 4: Login to target server B using ‘wlshop’ user and create .ssh directory if not already present

Step 5: applmgr.A> cat .ssh/id_rsa.pub | ssh wlshop@B ‘cat >> .ssh/authorized_keys’. It will ask for wlshop@B password. 

Step 6: Now you can login to B as ‘wlshop’ from server A without being prompted for password

applmgr.A> ssh wlshop@B

 -Anand

 

Categories: Unix/Linux