Tuesday, April 6, 2021

USING PUTTY TO SSH TO YOUR SERVER FROM WINDOWS

I think it is really important to show you how to use Putty tool to access your server via SSH connection. This is a very basic skill every server admin should know. Since this blog is aimed to helping babies (newbies with no knowledge about Linux and server at all), so I’ll write this simple tutorial as a basic guide every newbie should know. It means you can skip this post if you knew it already.

But first, it is better to know what the Putty is. Being a well-known and most used tool, Putty is basically a client for the SSH, Telnet, rlogin, and raw TCP computing protocols and as a serial console client. Its simplicity makes this tool widely used. The program is originally written for Windows-based computers but then it has been ported to various other operating systems, even on mobile devices running Symbian. The tool is compatible for Windows XP, Vista, 7 and even Windows 8.

Download Putty
You can download Putty here or via direct link here.

Now you have Putty on your computer. Assuming you have a server you wish to manage via SSH port, so here it is the way I use Putty which you can follow..

Step 1.
Download Putty.exe

Step 2.
Double-click it to launch the main interface. It should look like this..


Step 3.
Now enter the Host name of your server obtained from your provider. It can also be the IP address.

Step 4.
Leave the port field as it is (port 22 – default) unless your provider changed it to another port but they should tell you.

Step 5.
Make sure the “SSH” option is checked.


Step 6.
That’s it then click the “Open” button

Step 7.
Now you’ll see another window open. If it is your first time using Putty to SSH-ing your server, you may notice an alert like this one. Simply hit Yes button.


Step 8.
Putty will bring you to login to your server via SSH connection. In this case you may enter your root password.


Congratulation you are now getting access to your server via SSH. You can try some basic command. In this case I’ll try to see RAM usage in my playground server:

Command to use:

1
free -m

It will return like this..


Quick tip:

In Putty, you can use mouse right-click to paste any text. 

Link: http://www.servermom.org/using-putty-to-ssh-to-your-server-from-windows/46/

Monday, April 5, 2021

Copy files from/to remote server using PuTTY pscp

Once you install and setup PuTTY application you need to login to your server with hostname and port number details. 

Install PSCP as well and login to PuTTY terminal.


1.Download PSCP.EXE from Putty download (https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html) page

2.set New Path in environment variable  = C:\Program Files\PuTTY\pscp.exe

3.now open command prompt type pscp if pscp is successfully installed it will show its version.


Okey pscp now successfully setup.



Transferring file from server to localhost

Now we have to zip the directory which we want to copy because without zip we cant copy directory.


1. First zip a directory using putty 

   Goto the directory folder the make a zip file of that directory by following command = zip -r directoryName *

   From test server: zip -r ready_products * 

   It will make zip file of ready_products

   

   if you need unzip that folder enter unzip latest.zip

   

   if you need to delete the zip folder the enter unlink folder.zip or rm folder.zip

   

2.use the following command to copy file form remote server to the local system

So to copy the file /etc/hosts from the server example.com as user fred to the file c:\temp\example-hosts.txt, you would type

e.g: pscp -P 22 fred@example.com:/etc/hosts c:\temp\example-hosts.txt

   

    From test server : pscp -P 22 kldev@example.com:/var/www/project/storage/app/public/images/ready_products.zip C:\wamp64\www


Now Transferring file from localhost to remote server


1. pscp -P 22 filename_from_localhost kldev@server_ip_address:/server_folder_location


e.g.1 pscp -P 22 Library_Management.zip kldev@93.100.111.222:/var/www/Library_Management_Project/public_html/


e.g.2 pscp -P 22 ready_products.zip kldev@example.com:/var/www/project/storage/app/public/images/


Link 1 : https://stackoverflow.com/questions/6217055/how-can-i-copy-a-file-from-a-remote-server-to-using-putty-in-windows

Link 2: https://akshay-waingankar95.medium.com/copy-files-from-to-remote-server-using-putty-pscp-7567a0631c9d

Link3: https://www.ssh.com/ssh/putty/putty-manuals/0.68/Chapter5.html

Tuesday, March 30, 2021

Vuex

 

import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
const url = "https://icanhazdadjoke.com";
const headers = { Accept: "application/json" };
export default new Vuex.Store({
state: {
currentJoke: "This is a joke",
allJokes: []
},
mutations: {
//syncrous
setCurrentJoke(state, payload) {
state.currentJoke = payload;
state.allJokes.push(payload);
}
},
actions: {
//asyncronous
async setCurrentJoke(state) {
const joke = await fetch(url, { headers });
const j = await joke.json();
state.commit("setCurrentJoke", j.joke);
}
},
modules: {},
getters: {
getCurrentJoke: state => state.currentJoke,
getAllJokes: state => state.allJokes
}
});
<template>
<div class="home shadow-xl bg-gray-200 w-8/12 mx-auto p-20">
<h2 class="text-3xl text-blue-600 font-extrabold">Can I Haz Dad Jokes</h2>
<h3 class="h-40 text-black">{{joke}}</h3>
<button
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full mt-10 focus:outline-none"
@click="addJoke"
>Add Joke</button>
</div>
</template>
<script>
// @ is an alias to /src
import { mapActions, mapGetters } from "vuex";
export default {
name: "Home",
methods: {
...mapActions({ addJoke: "setCurrentJoke" })
// addJoke() {
// this.$store.dispatch("setCurrentJoke");
// this.setCurrentJoke();
// }
},
computed: {
...mapGetters({ joke: "getCurrentJoke" })
// joke() {
// return this.getCurrentJoke;
// }
}
// mounted() {
// this.joke = this.$store.getters.getCurrentJoke;
// }
};
</script>
<style scoped>
.home {
height: 400px;
max-height: 500px;
}
h3 {
font-size: 2.5rem;
}
</style>

laravel mix - lazy loading Vue components

STEP:1

Run this following command

*npm install --save-dev babel-plugin-dynamic-import-webpack

*npm install --save-dev babel-plugin-syntax-dynamic-import


STEP:2

Create a file in the root of your Laravel application called .babelrc with the following contents.


{

    "plugins": ["syntax-dynamic-import"]

}


STEP:3

Update your webpack.mix.js file to the following:


let mix = require('laravel-mix');


// Override mix internal webpack output configuration

mix.config.webpackConfig.output = {

    chunkFilename: 'js/pages/[name].bundle.js',

    publicPath: '/',

};


STEP:4

Instead of loading components in the standard way,


Vue.component(

    'example-component',

    require('./components/ExampleComponent.vue') 

);


We need to use the lazy loading import method.


Vue.component(

    'example-component', 

    () => import(

        /* webpackChunkName: "example-component" */

        './components/ExampleComponent.vue'

    )

);


Ref:https://acode.ninja/posts/laravel-mix-lazy-loading-vue-components/