How to fix ssh-add -K issue with Mac OS Sierra?

Standard

Before Mac OS Sierra, using this line of code save your time adding ssh keys once in your keychain:

ssh-add -K ~/.ssh/{your key}

but recently there is some issue with Mac OS new version and all your keys added to keychain reset on startup.

to fix this issue I found a solution with might be helpful.

  1. create a bash file containing these codes (~/.ssh/add_ssh_keys.sh):
count=`ssh-add -l |grep -v "The agent" |wc -l|awk '{print $1}'`
 if [ "0" == "${count}" ]
 then
 arr=`cd ~/.ssh && find id_rsa* -not -path '*.pub'`
 for key in ${arr[@]}
 do
 ssh-add -k ~/.ssh/${key}
 done
 fi
  1. make this file executable:
chmod +x ~/.ssh/add_ssh_keys.sh
  1. add this file to your Mac launch (~/Library/LaunchAgents/ssh_fixer.plist):
<plist version="1.0">
 <dict>
 <key>Label</key>
 <string>add_ssh_keys</string>
 <key>ProgramArguments</key>
 <array>
 <string>/Users/{YOUR USERNAME}/.ssh/add_ssh_keys.sh</string>
 </array>
 <key>RunAtLoad</key>
 <true/>
 </dict>
 </plist>
  1. now restart your Mac!

 

That’s it! 😎

How to create SSH Proxy Tunnel with PuTTY

Standard

Configuring PuTTY

  1. Fire up the client and enter the hostname and port
  2. Type in a title under Saved Sessions and press Save
  3. On the left side, go to Connection->SSH->Tunnels
  4. In Source Port enter 8080 (this can be configured to be whatever you want, just remember it)
  5. Choose the Dynamic radio button under Destination
  6. Press Add, you should then see D8080 in the box above
  7. Go back to Session on the left side and then press Save to save the changes

SOCKS Proxy

To utilize the tunnel to its full benefit, you need to set up a SOCKS proxy in your browser. Will describe how to use the Proxifier. It works for all Windows applications.

  1. Download Proxifier.
  2. Go to the Profile -> Proxy Servers
  3. Click Add…
  4. Enter localhost in the Address box
  5. Enter 8080 in the Port box
  6. Check SOCKS Proxy and make sure the SOCKS v5 radio is checked
  7. Press Ok to save

enjoy it… ;)

How to restore MySQL Database via SSH/Telnet

Standard

Open your SSH/Telnet client and log into your website. The command line prompt you will see will vary by OS. For most hosting companies, this will bring you into the FTP root folder.

How to restore a cPanel Full backup from another server

Standard

If you don’t have a complete cPanle backup and have the Home Directory contents only, then I suggest you the following step,
1) Create New Account in WHM
2) Upload the Home Dir backup file (ZIP or TAR or GZ) to the corresponding accounts home path
3) Login into SSH, browse to the corresponding account’s home path and extract it using the tar command (only if the file is too big) else if the backup file is small you can extract it within the cPanel’s file manager itself.

If you can get Complete cPanel Backup File:
1) In the source cPanel goto Backups Section > Generate a Full Backup. Make the full backup file to be uploaded into some other site’s public path
2) Now SSH into your VPS’s root path
3) Create a directory called home2 in the root path and browse inside it
4) Now get the complete backup file using wget command
5) Once the file is downloaded, you can now login into the WHM as root and in the Left sidebar choose Complete Restore/cpmove restore
6) It will scans and displays the file you uploaded into the home2 folder
7) Now enter the cPanel’s username ( can be found in the file itself ) and click restore.