

Some local systems may have multiple interfaces and/or multiple IP addresses. $ ssh -C 192.168.122.22 Compression Specify Source Address Compression can be enabled per session with -C parameter. Compression can provide benefits is the data is high compression rate like text. SSH can save from bandwidth and network usage by compressing its network traffic. $ ssh -X 192.168.122.22 firefox X11 Forwarding Compression Port forwarding should be enabled while connecting to the remote system. For example I want to connect from local system through a remote system. The general definition of port forwarding is tunneling local or remote system ports each other. Port forwarding is useful feature provided by SSH. $ ssh -F ssh_config 192.168.122.22 Explicit Configuration Port Forwarding Alternative configuration can be specified with -F parameter like below. SSH configuration generally resides on the /etc/ssh/ssh_config or ~/.ssh/config. $ ssh 192.168.122.22 "ip address show" Run Command Remotely Explicit Configuration This will run command ip address show on the remote system. SSH provides the ability to run commands remotely without opening an interactive bash shell. To run single line command on the remote hosts opening new shell and typing command may become hard work for us. ssh/id_rsa Explicitly Specify Keys Run Command Remotely We can provide keys explicitly with the -i parameter like below. SSH behaivour is by default using keys /home/ismail/.ssh/id_rsa.pub and /home/ismail/.ssh/id_rsa but this is not practical some times. $ ssh-copy-id Key Based Authentication Explicitly Specify Keys By default, our public key is /home/ismail/.ssh/id_rsa.pub Our public key is deployed to the remote users authorized keys database. Remote username and host provided like below. Deployment is easy because of SSH tool named ssh-copy-id . First, we should deploy our public key to the remote system. We can use these keys to automatically authenticate without providing any password. If we want to encrypt then enter the password, if not just press enter and skip.Įnter passphrase (empty for no passphrase):Įnter same passphrase again: Key Based Authentication Especially private key named id_rsa is important. Keys can be protected by encrypting them.If we want to change default values we can provide them if not just press enter and skip.Įnter file in which to save the key (/home/ismail/.ssh/id_rsa): The exact path is /home/ismail/.ssh/ and keys are named id_rsa.pub, id_rsa . By default, keys are stored in the users home directory.To use key-based security public and private keys should be created for the user.ĭuring key generation process some questions are asked. Key-based or certificate-based authentication is more secure than password-based authentication. The default one is password-based authentication as we previously did. SSH provides different protocols for authentication. SSH is very advanced and feature-full protocol.
SSH SHELL SCRIPT EXAMPLE KEYGEN
$ ssh -p 22 192.168.122.22 Specify Port Number Create Public-Private Keys/Certificates With SSH Keygen In some cases the port number can be different than 22 so the remote port number should be provided to the ssh explicitly with -p parameter like below. Ssh clients also assumes remote system uses default port number. Ssh protocol uses TCP port 22 by default.


$ ssh -l root 192.168.122.22 Specify Username Specify Port Number We can provide the username with -l parameter like below. What is we need to use different username for the remote connection? Adding username to the remote system IP address or hostname with sign like below can solve this. In the previous example username is supplied by the session. $ ssh 192.168.122.22 Connect To Remote Specify Username Explicitly Simply current users username is used for remote system. The user name is supplied from current user. Simple usage of ssh is just providing hostname or IP address of remote system and connect.
