User Tools

Site Tools


tutorials:remote_access

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorials:remote_access [2011/02/01 02:58] – [SCP] chkuotutorials:remote_access [2019/01/11 17:35] (current) – [Key] chkuo
Line 2: Line 2:
  
 ===== SSH ===== ===== SSH =====
 +
 ==== Login ==== ==== Login ====
 ''ssh'' (SSH client) is a program for logging into a remote machine. The typical usage is ''ssh user@hostname'', for example: <code bash>ssh jake@168.192.1.1</code> ''ssh'' (SSH client) is a program for logging into a remote machine. The typical usage is ''ssh user@hostname'', for example: <code bash>ssh jake@168.192.1.1</code>
Line 17: Line 18:
  
 ==== Key ==== ==== Key ====
-To generate key-pairs, use: <code bash>ssh-keygen -t 'rsa'</code> +To generate key-pairs, use: <code bash>ssh-keygen -t rsa -b 4096</code>
  
-This command will create a pair of private key (''~/.ssh/id_rsa'') and public key (''~/.ssh/id_rsa.pub''). To enable authentication on a remote host, append the public key to the ''~/.ssh/authorized_keys'' file in the remote host.+This command will create a pair of private key (''~/.ssh/id_rsa'') and public key (''~/.ssh/id_rsa.pub''). To enable authentication on a remote host, append the public key to the ''~/.ssh/authorized_keys'' file in the remote host (this file should be owned by the user and have the ''644'' permissions). 
 + 
 +If the home directory is encrypted, ''authorized_keys'' would not work while within the home directory before the user is logged in. Move the ''authorized_keys'' file and modify ''/etc/ssh/sshd_config'' accordingly. 
 +For example (see [[https://help.ubuntu.com/community/SSH/OpenSSH/Keys#Troubleshooting]]: 
 +  * set up ''/etc/ssh/<username>'' (owned by user, 755 permissions).  
 +  * in ''/etc/ssh/sshd_config'', add ''AuthorizedKeysFile    /etc/ssh/%u/authorized_keys'' 
 +  * restart sshd: ''sudo service ssh restart'' 
 + 
 +==== Keep alive ==== 
 +To prevent the ssh sessions from being disconnected due to inactivity, add the following lines to ''/etc/ssh_config'' on the client: 
 +<code> 
 +ServerAliveInterval 60 
 +ServerAliveCountMax 60 
 +</code> 
 +This sends a signal every 60 seconds for a maximum of 60 times (one hour) from the client to the server. 
 + 
 +If you do not have the permission to make this modification, put those lines to ''~/.ssh/config'' (create the file is necessary).
  
  
Line 38: Line 55:
  
 To copy an entire directory, use: <code bash>scp -r ~/foo_dir 168.192.1.1:~</code> To copy an entire directory, use: <code bash>scp -r ~/foo_dir 168.192.1.1:~</code>
- 
tutorials/remote_access.1296500323.txt.gz · Last modified: 2011/02/01 02:58 by chkuo