Wednesday, September 3, 2014

[Quick Tips] : Top 15 SSH Server interview Questions & Answers

Top 15 SSH Server interview Questions & Answers

Q:1 What is the default port & configuration file of SSH Server ?
Ans: 22 is default port  for ssh and  ‘/etc/ssh/sshd_config’ is the configuration file.
Q:2 How to change the default ssh port in linux ?
Ans: To change the port , first edit the file ‘ /etc/ssh/sshd_config ‘ , change the  vaule of parameter ‘ port 22 ‘, now restart the ssh service.
Q:3 What is the configuration file of ssh client ?
Ans: ‘ /etc/ssh/ssh_config ‘ is configuration file for ssh client.
Q:4 What is SSH port forwarding ?
Ans: SSH Port Forwarding, sometimes called SSH Tunneling, which allows you to establish a secure SSH session and then tunnel arbitrary TCP connections through it. Tunnels can be created at any time, with almost no effort and no programming.
Syntax : ssh -L localport:host:hostport user@ssh_server -N
where: 
-L – port forwarding parameters  
localport – local port (chose a port that is not in use by other service) 
host – server that has the port (hostport) that you want to forward 
hostport – remote port 
-N – do not execute a remote command, (you will not have the shell, see below) 
user – user that have ssh access to the ssh server (computer) 
ssh_server – the ssh server that will be used for forwarding/tunneling
Without the -N option you will have not only the forwarding port but also the remote shell.
Q:5 How to disable the root login in linux server ?
Ans: Open the file ‘ /etc/ssh/sshd_config ‘ and chnage the paramenter ‘PermitRootLogin yes’ to ‘PermitRootLogin no’ & restart the ssh service.
Q:6 How to allow only specific users to ssh your linux server ?
Ans: Open the file ‘/etc/ssh/sshd_config’ and add the parameter ‘AllowUsers user1 user2′ & then restart the ssh server.
Q:7 How to enable debugging in ssh command ?
Ans: To enable debugging in ssh command use ‘-v’ option like ‘ssh root@www.linuxtechi.com -v’. To increase the debugging level just increase the number of v’s.
Q:8 What is the difference between ssh & Telnet ?
Ans: In ssh communication between client & server is encrypted but in telnet communication between the client & server is in plain text . We can also say SSH uses a public key for authentication while Telnet does not use any authentication.SSH adds a bit more overhead to the bandwidth compared to Telnet.Default port of ssh is 22 and for telnet 23.
Q:9 What is use of sshpass command in linux ?
Ans: sshpass is a command which allows us to automatically supply password to the command prompt so that automated scripts can be run as desired by users. sshpass supplies password to ssh prompt using a dedicated tty , fooling ssh to believe that a interactive user is supplying password.
Q:10 What is the use of scp command ?
Ans: SCP stands for Secure Copy ,it copies files between hosts over a  network.  It uses ssh for data transfer &  uses the same authentication and provides the same security as ssh. Unlike rcp, scp will ask for passwords or passphrases if they are needed for authentication.
Q:11 What is the use of blowfish options in scp command ?
Ans: Using blowfish options in scp command , we can increase the speed, by default scp uses the Triple-DES cipher to encrypt the data being copied.
Example : scp -c blowfish /home/itstuff.txt root@mail.linuxtechi.com:/opt/
Q:12 How to limit the bandwidth used by scp command ?
Ans: We can limit the bandwidth used by the scp command using the -l option as shown in the syntax.’#scp -l bandwidth_limit filename username@remote-host:/folder-name’ , where bandwidth_limit is numeric to be specified in kilobits per second.
Q:13 How to enable passwordless ssh authentication in Linux ?
Ans: To Implement passwordless or Keys based authentication we have to generate Public and Private keys , Copy the Pubic keys to remote Linux servers either manually or by ssh-copy-id command.ssh-copy-id command will automatically copy the contents of id_rsa.pub file to ‘~/.ssh/authorized_keys’ file of remote linux server.
Q:14 How to check SSH server’s Version ?
Ans: Using the command ‘ ssh -V ‘ we can find the ssh server’s version.
Q:15 How to Copy the file “server.txt” from the local machine to a remote host using port 2751 in /opt folder.
Ans:  scp -P 2751 /home/server.txt root@mail.linuxtechi.com:/opt

No comments: