Saturday, August 9, 2014

Transfer files from one linux server to another linux server

scp from one remote server to another remote server

If you are trying to transfer files from one remote server to another remote server using scp and you are getting permission denied error, here is the solution for you.

Suppose you are using system A and you want to transfer files from system B to system C and you are trying
scp user1@systemB-IP:/location/sourcefile user2@systemC-IP:/location/targetFile
But you are getting permission denied error

You should use
ssh user1@systemB-IP scp /location/sourceFile user2@systemC-IP:/location/targetFile
But still you are getting permission denied error, try
ssh -t user1@systemB-IP scp /location/sourceFile user2@systemC-IP:/location/targetFile
Example :
IP of system A - 192.168.0.11
IP of system B - 192.168.0.12
IP of system C - 192.168.0.13

Source file location on system B - /opt/lampp/htdocs/install.log
Destination location on system C - /opt/logs

You are log in to system A and you want to transfer file from system B to system C. Run following command :
ssh -t root@192.168.0.12 scp /opt/lampp/htdocs/install.log root@192.168.0.13:/opt/logs


Solution : 2
Save public key file of your system (system A) into system B and system C.

scp $HOME/.ssh/filename.pub root@192.168.0.12:/root/.ssh/authorized_keys

scp $HOME/.ssh/filename.pub root@192.168.0.13:/root/.ssh/authorized_keys

and now run
scp root@192.168.0.12:/opt/lampp/htdocs/install.log root@192.168.0.13:/opt/logs

Pseudo-terminal will not be allocated because stdin is not a terminal

Pseudo-terminal will not be allocated because stdin is not a terminal

if you get this error while log into another Linux account using ssh, here is the solution.

Use -t -t with ssh.
ssh -t -t hostname
Example :
ssh -t -t user@192.168.0.7

unknown job `servicename`

unknown job error ubuntu

Service is installed but when you try to start, stop or restart, it gives you unknown job error. 
If you are facing this problem in root account, here is the solution.

Use sudo with your command but there should be no need to use sudo in root account. Use sudo and if your command is executed successfully, it means you have not created alias for sudo.

Add this line in .bashrc file of root.
alias service="sudo service"
You will find the file here i.e. /root/.bashrc

ubuntu - root login not possible through ssh

ubuntu 14.04 - Enable root login for ssh

If you are trying to log into root account of ubuntu system using ssh and you are getting permission denied error. You are quite sure that your password is correct but still you are facing this error. It means root account is disabled for ssh.
Follow the steps to enable it.

Open file /etc/ssh/sshd_config on your ubuntu system.
Replace line
PermitRootLogin without-password
with
PermitRootLogin yes
Restart ssh.
Now try to log into root account using ssh.