Skip to main content

Posts

Showing posts with the label ssh

Toggle SSH Session using SSH Escape Character

When you’ve logged on to the remotehost using ssh from the localhost, you may want to come back to the localhost to perform some activity and go back to remote host again. In this case, you don’t need to disconnect the ssh session to the remote host. Instead, follow the steps below. 1. Login to remotehost from localhost: dipin@linuxgeek:~$ ssh user@remotehost 2. Now you will be connected to the remotehost and your prompt will read: remotehost$ 3. Now to come back to the localhost temporarily, type the escape character ~ followed by Control-Z. You won't see the ~ character on the screen immediately after you type it, until you press and press enter. So, on the remotehost enter the following key strokes: ~ remotehost$ ~^Z [1]+ Stopped ssh user@remotehost dipin@linuxgeek:~$ 4. Now you are back to the localhost and the ssh remotehost client session runs as a typical UNIX background job, which you can check as shown below: dipin@linuxgeek:~$ jobs [1]+ Stopped ssh user@remotehost 5. ...

How to generate a SSH key in Linux ( ubuntu debian fedora)

To generate a SSH key pair use the command 'ssh-keygen'. $ ssh-keygen -t dsa This will ask you to enter a file to save the key. The default is '.ssh/id_dsa' in your home directory. Generating public/private dsa key pair. Enter file in which to save the key (/home/dipin/.ssh/id_dsa):  Press 'Enter' to accept the default. Now it will ask for a passphrase and will ask you to re-enter to confirm. Generating public/private dsa key pair. Enter file in which to save the key (/home/dipin/.ssh/id_dsa): /tmp/key Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /tmp/key. Your public key has been saved in /tmp/key.pub. The key fingerprint is: 8d:f7:d8:d1:b6:ea:c2:a7:a4:fd:ff:6f:95:06:bb:0a dipin@dipinkrishna.info You will get a private key file and a public key file with '.pub' extension.

SSH login without password

For this you required to generate your own personal set of private/public pair. ssh-keygen is used to generate that key pair for you. On the user’s home directory, on the localhost, type [local-host]$ ssh-keygen -t dsa This will ask you a passphrase. A passphrase is a sequence of words or other text used to control access to a computer system, program or data. A passphrase is similar to a password in usage, but is generally longer for added security. Once entered the passphrase you will be prompted to enter the same passphrase again for confirmation. The private key was saved in .ssh/id_dsa and the public key .ssh/id_dsa.pub. Now, copy the public key to the remote machine [local-host]$ scp .ssh/id_dsa.pub user@remote:~/.ssh/id_dsa.pub Now, login into the remote machine and go to the .ssh directory on the server side [local-host]$ ssh user@remote [remote-host]$ cd .ssh Now, add the client’s public key to the known public keys on the remote machine. [remote-host]$ cat id_d...