sabato 11 giugno 2011

Configure FTP and SSH for remote access

CONFIGURING THE SSH SERVER

First step, we need to create a backup of the configuration file, so we can reset quickly the basic configuration because during editing important informations may be lost.

$ sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup


Copy also the file containing the security key automatically generate by OpenSSH. You can arbitrarily choose this folder.

$ sudo cp /etc/ssh/ssh_host*_key* /directory/backup

Now open sshd_config with nano (text editor), and we can easly modify it, because it's all commented.



We can start to disable the root's login changing the value of PermitRootLogin:

PermitRootLogin no

and uncomment IgnoreUserKnownHosts, so you can log in only with a password an username.

IgnoreUserKnownHosts yes


Then add some users that we want enable login

AllowUsers john jack alan


We can add groups too.

AllowGroups group1 group2 group3

Now start ssh.

$ sudo /etc/init.d/sshd start

$ sudo /etc/init.d/sshd restart //reboot if ssh had already started

With this configuration we can access the server via SSH. Anyway if you want customize more connection parameters or OpenSSH's settings, you can read the documentation in Ubuntu Server with this command:

$ man sshd_config

that gives you more details.

CONFIGURING THE FTP SERVER

Ok, now we have to configure the ftp server. The configuration file of vsftpd is in /etc/vsftpd.conf, open it with nano.

$ sudo nano /etc/vsftpd.conf

Uncomment the following lines:
  •  local_enable - to enable local connection via FTP
  • write_enable - to enable writing to the connected users via FTP
You can access the server with login or anonymously (if you want disable it, go to anonymous_enable -> "anonymous_enable no")

To allow access to other users as well as ours , it is necessary to create new, associate to each a directory and enable them to access via FTP.


$ sudo mkdir /home/pippo
$ sudo useradd -d /home/pippo -g users -s /bin/false pippo
$ sudo passwd pippo
$ sudo chwon -R pippo.users /home/pippo
$ sudo touch /etc/vsftpd.user_list
$ sudo echo "pippo" > /etc/vsftpd.user_list
Finally, add to the configuration file the following lines:


For more information, i suggest you read the official documentation.

Now:

$ sudo /etc/init.d/vsftpd start
or
$ sudo /etc/init.d/vsftpd restart

R.

Nessun commento:

Posta un commento