create ssh rsa key files and use them for authentication
Create the rsa key, if ~/.ssh directory doesn’t exit yet, create it by mkdir ~/.ssh
[code language=”shell”]
cd ~/.ssh
ssh-keygen -t rya -C put your email address or a username or any kind of label text
[/code]
After you entered the above command it give you the prompt below, just press enter or type a file name you like and then enter.
[code language=”shell”]
Enter file in which to save the key (/home/yourusername/.ssh/id_rsa)
[/code]
After you entered above, it will ask you to enter a passphrase, you can either skip it by press enter or create one by giving a passphrase and give one more time to confirm.
Now you should have have the file id_rsa and id_rsa.pub two files created in ~/.ssh
[code language=”shell”]
ls
id_rsa id_rsa.pub
[/code]
Done creating your rsa key files. The below are for setting up rsa pub key authentication for accessing remote server if you are the owner of the remote server. Otherwise, you just have to give the id_rsa.pub file to your system admin of the remote server and he/she can set it up for you.
Assume you have an account on a virtual host or remote server at /home/yourname/, logon to the server and copy the content in your id_rsa.pub that you just created from the above to the file on the remote server /home/yourname/.ssh/authorized_keys
[code language=”shell”]
cd ~/.ssh
vim authorized_keys
[/code]
Go back to your local machine, assume the remote server ip is 123.23.23.1, then you can logon by this command, which will not ask you for a password because it will use your id_rsa.pub for authentication. It will ask you a passphrase if you created passphrase when you were creating the rsa key files.
[code language=”shell”]
ssh yourname@123.23.23.1
[/code]
Another quicker way to logon is to set ssh config file. Create a file ~/.ssh/config and put this in it
[code language=”shell”]
Host someservername
HostName 123.23.23.1
User yourname
IdentityFile ~/.ssh/id_rsa
[/code]
Now you can logon by
[code language=”shell”]
ssh someservername
[/code]
Download a file from the remote server like this
[code language=”shell”]
scp someservername:/home/yourname/somefile.txt ./
[/code]
Upload a file from your local to the remote server like this
[code language=”shell”]
scp somefile.txt someservername:/home/yourname/
[/code]
Search within Codexpedia
Search the entire web