SSH Interview Questions and answers

SSH Interview Questions and answers

SSH Interview Questions and answers

Here are all SSH Interview Questions and answers

  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.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.

    3. What is the configuration file of ssh client ?
    Ans: ‘ /etc/ssh/ssh_config ‘ is configuration file for ssh client.

    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

    -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.

    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.

    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.

    7. How to enable debugging in ssh command ?
    Ans: To enable debugging in ssh command use ‘-v’ option like ‘ssh -v’. To increase the debugging level just increase the number of v’s.

    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.

    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.

    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.

    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

    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.

    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 file to ‘~/.ssh/authorized_keys’ file of remote linux server.

    14. How to check SSH server’s Version ?
    Ans: Using the command ‘ ssh -V ‘ we can find the ssh server’s version.

    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

  2. SSH or Telnet? Why?

Ans: Both SSH and Telnet are network Protocol. Both the services are used in order to connect and communicate to another machine over Network. SSH uses Port 22 and Telnet uses port 23 by default. Telnet send data in plain text and non-encrypted format everyone can understand whereas SSH sends data in encrypted format. Not to mention SSH is more secure than Telnet and hence SSH is preferred over Telnet.

  1. How to add welcome/warning message as soon as a user login to SSH Server?

Ans: In order to add a welcome/warning message as soon as a user logged into SSH server, we need to edit file called ‘/etc/issue’ and add message there.

  1. Is it possible to copy files over SSH? How?

Ans: Yes! We can copy files over SSH using command SCP, stands for ‘Secure CopY’. SCP copies file using SSH and is very secure in functioning.

  1. Is it possible to pass input to SSH from a local file? If Yes! How?

Ans: Yes! We can pass input to SSH from a local file. We can do this simply as we do in scripting Language. Here is a simple one liner command, which will pass input from local files to SSH.

  1. Is it possible to trace unauthorized login attempts to SSH Server with date of Intrusion along with their corresponding IP.

Ans: Yes! we can find the failed login attempts in the log file created at location ‘/var/log/secure’. We can make a filter using the grep command as shown below.

…..Best Of Luck…..

Leave a Reply

Your email address will not be published. Required fields are marked *