Monthly Archives: September 2016

Change default password for Oracle 11g Database

oracle11g
To change the default password for SYS and SYSTEM users use the trick.

1. Run in shell:

sqlplus  / as sysdba

2. Change password for SYS:

SQL> alter user SYS identified by "your-super-password";

3. Change password for SYSTEM:

SQL> alter user SYSTEM identified by "your-super-password";

Thanx to http://stackoverflow.com/a/740884

Using RSYNC to backup (synchronize) folders

rsync
If you want to synchronize two folders use next snippets.

1. Sync folder “source” content to “target” folder:

rsync -arpv --delete /mnt/source/ /mnt/target

Notice trailing slash for “source” folder!

2. Sync whole folder “source” to “parent” folder:

rsync -arpv --delete /mnt/source /mnt/parent

More info https://linux.die.net/man/1/rsync

Generate SSH key (identity)

ssh
To generate SSH key you have to do following:

1. Install any SSH client (if absent).

2. Show existing keys:

ls -la ~/.ssh

It can be empty.

3. Generate key itself:

ssh-keygen -t rsa -b 4096 -C "your@email.com"

You’ll be prompted to enter the path to store the key. Also, you can enter a passphrase. But it can be empty in some cases.

4. Check for new key:

ls -la ~/.ssh

You’ll see something like:

-rw-r–r– 1 dtv 197121 1679 jun 11 2016 id_rsa
-rw-r–r– 1 dtv 197121 400 jun 11 2016 id_rsa.pub

5. Run SSH agent to add new key:

eval "$(ssh-agent -s)"

6. Add SSH key:

ssh-add ~/.ssh/id_rsa

Thanx to https://help.github.com/articles/generating-an-ssh-key/

Multiple SSH keys configuration

ssh-keys
If you are using, for example GIT, it may be needed to use different ssh keys for different servers. By default git client uses “~/.ssh/id_rsa” private key.
And you’ll get the error like:

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

If you want to use another ssh key, you should load it before with ssh-add command each time.

To avoid the issue you can specify the ssh key for certain server.
Just create (or update) file “~/.ssh/config” with content:

Host  someserver.com
  HostName                  someserver.com
  Port                      22
  PreferredAuthentications  publickey
  IdentityFile              "C:\Users\user42\.ssh\private-ssh-key-file"

Thanx to
https://confluence.atlassian.com/bitbucket/configure-multiple-ssh-identities-for-gitbash-mac-osx-linux-271943168.html
and https://gist.github.com/jexchan/2351996