Working at remote server through ssh

Configuring access without the password

Configuring access is performed as follows:

  • locally rsa key is generated by the command ssh-keygen -t rsa
  • on the server file sshd_config is configured:
# Should we allow Identity (SSH version 1) authentication?
RSAAuthentication yes
  
# Should we allow Pubkey (SSH version 2) authentication?
PubkeyAuthentication yes
 
# Where do we look for authorized public keys?
# If it doesn't start with a slash, then it is
# relative to the user's home directory
AuthorizedKeysFile    .ssh/authorized_keys
  • the public part of the key is copied to $HOME/.ssh/authorized_keys. This can be done using utility  ssh-copy-id:

ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote.server.host

Connection to the server

  • If the port is standard:

ssh user@remote.server.host

  • If the port isn’t standard:

ssh -P PORT user@remote.server.host

File copying

  • command for copying local SourceFile to a remote host:
 scp SourceFile user@host:/directory/TargetFile
  • command for copying SourceFile from a remote host:
 scp user@host:/directory/SourceFile TargetFile
  • if ssh is running on another port then the port should be specified by the key -P:
scp -P port user@host:/directory/SourceFile /directory/TargetFile

Screen

Screen is an utility for remote management of screens. It allows to run a process by ssh and in this case the process will continue to work in the background.

  • for running a program:
screen <command_to_run_the_program>
  • view all running screens:
screen -list

or

screen -ls
  • to disconnect from the screen (herewith the work will be continued)
Ctrl-a d
  • connect to disconnected screen (if only one session id should not be specified)
screen -r [SessionID]
  • connect to connected screen (multiscreen mode)
screen -x [SessionID]
  • switch between the screens:
Ctrl-a " - select from list
Ctrl-a Space - forward
Ctrl-a BackSpace - backward
Ctrl-a № - switch to specified number (numbered from 0)
Ctrl-a Ctrl-a - switch to the previous screen.

You can read about screen here.

ShareShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on VKEmail this to someone