I post below some useful SSH commands
Secure Copy File Transfer
Secure Copy File Transfer
SCP copies files between hosts on a network. It uses ssh for data transfer, and uses the same authentication and provides the same security as ssh. Some examples here
From a remote host to local host
More that one file from localhost to remote host
Secure Copy directory from local to remote host
SSHFS - Mouting partitions over SSH
Then run :
scp -P10022 192.168.2.10:/home/stelios/Desktop/Etherchannel.zip /home/stelios/Desktop/
Etherchannel.zip 100% 137KB 136.6KB/s 00:00
More that one file from localhost to remote host
scp -P10022 test01.txt test02.txt 192.168.2.10:/home/stelios/Desktop/
test01.txt 100% 0 0.0KB/s 00:00
test02.txt 100% 0 0.0KB/s 00:00
From the local host to a remote host
scp -P10022 /home/stelios/Desktop/Multicast.zip 192.168.2.10:/home/stelios/Desktop/
Multicast.zip 100% 75MB 1.5MB/s 00:49
Secure Copy directory from local to remote host
scp -P10022 -r /home/stelios/Desktop/scp_test 192.168.2.10:/home/stelios/Desktop/
WHowe_gns3_vbox.pdf 100% 1902KB 1.9MB/s 00:00
ssh 192.168.2.10 -p 10022 uptime
21:29:46 up 2:25, 2 users, load average: 0.21, 0.13, 0.30
ssh 192.168.2.10 -p 10022 'ps aux | echo $HOSTNAME'
desktop
ssh 192.168.2.10 -p 10022 uname -a
Linux desktop 3.2.0-29-generic-pae #46-Ubuntu SMP Fri Jul 27 17:25:43 UTC 2012 i686 athlon i386 GNU/Linux
if command needs terminal then use -t option to force ssh to allocate pseudo-tty, like :
ssh 192.168.2.10 -p 10022 top
TERM environment variable not set.
ssh 192.168.2.10 -p 10022 -t top
top - 08:47:40 up 8 min, 2 users, load average: 0.01, 0.47, 0.42
Tasks: 161 total, 1 running, 160 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.1%sy, 0.0%ni, 99.9%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1931440k total, 729236k used, 1202204k free, 60528k buffers
Swap: 1963004k total, 0k used, 1963004k free, 394952k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2565 stelios 20 0 2836 1156 860 R 0 0.1 0:00.05 top
1 root 20 0 3652 1968 1248 S 0 0.1 0:00.81 init
2 root 20 0 0 0 0 S 0 0.0 0:00.00 kthreadd
SSHFS - Mouting partitions over SSH
Mount a partition located on a remote machine to your local machine.
For this you need to install sshfs.
For this you need to install sshfs.
sudo apt-get install sshfs
Then run :
sshfs -p 30022 192.168.2.10:/media/Storage01/copy_Audio/Audio/Music /home/stelios/temp/
.ssh/config
Use the .ssh/config to enter convenient aliases for the remote hosts
Use the .ssh/config to enter convenient aliases for the remote hosts
cat .ssh/config
Host remote-desktop
HostName myremotemachine
Port 10022
User stelios
Host remote-fileserver
HostName myremotemachine
Port 30022
user stelios
ssh remote-desktop 'cat /etc/lsb-release'
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"
ssh remote-fileserver 'cat /etc/lsb-release'
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04.4 LTS"
No comments:
Post a Comment