Advertisement
Kyfx

Accessing the CLI using SSH

Oct 9th, 2015
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. Accessing the Command –line using SSH
  2.  
  3. The secure shell, SSH, is used to securely run a shell on a remote system. If you have a user account on a remote Linux system providing SSH service, ssh is the command normally used to remotely log in the system. The ssh command can also be used to run a individual command on a remote system.
  4.  
  5. Here is some examples of ssh command syntax for remote login and remote executions:
  6.  
  7. Create a remote interactive shell as current user, then return when you are done (exit)
  8.  
  9. [root@kyfx ~]# ssh remote-host
  10. root@remotehost’s password:
  11. [root@remotehost ~]# exit
  12. Connection to remote-host closed
  13. [root@kyfx ~]#
  14.  
  15. Connect to a remote shell as a different user(remote user) on a selected host(remote host):
  16.  
  17. [root@kyfx ~]# ssh remoteuser@remotehost
  18. root@remotehost’s password:
  19. remotehost.example.com
  20. [root@kyfx ~]#
  21. The w command displays a list of user currently logged in to the computer. This is especially useful to show which user are logged in using ssh from which remote locations, and what they are doing.
  22.  
  23. Ssh host keys
  24. SSH secures the communication through public-keys encryption. When an SSH client connects to an SSH server, before the client logs in, the server sent it a copy of its public key. This is used to set up the secure encryption for the communication channel and to authenticate the server to the client.
  25. The first time a user uses SSH to connect to a particular server, the SSH command stores the server’s public key in the user’s ~/ .ssh/known_hosts file. Then every time the user connects after that, it makes sure that it gets the same public key from the server by comparing the server’s entry in the ~/ .ssh/known_hosts file to the public key the server sent. If the key do not match, the client assumes that the network traffic is being hijacked or that the server has been compromised and breaks the connection.
  26. This means that if server’s public key is changed (because the key was lost due to maintenance failure or some legitimate reason), users will need to update their ~/ .ssh/known_hosts files to remove old entry in order to log in.
  27. • Host IDs are stored in ~/.ssh/known_hosts on the local computer(end user)
  28. o Verify it by using command
  29.  $cat ~/.ssh/known_hosts
  30. • Host keys are stored in /etc/ssh/ssh_host_key*
  31. o $ ls /etc/ssh/*key*
  32.  
  33. Note: An even better approach is to add entries matching a server’s ssh_host_*key.pub files to user ~/.ssh/known_hosts or the system-wide /etc/ssh/ssh_known_hosts in advance when the public key change. See ssh-copy-id(1) for an advanced way to manage ssh keys. [..continued]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement