scp different ssh port

scp different ssh port

scp different ssh ports (one or two different ports)

You can use ~/.ssh/config to specify the ports to use for the hosts (and for setting many other nice things; check the man page man ssh_config):

# ~/.ssh/config

Host 67.12.21.133
  Port 6774

Host 67.129.242.40
  Port 6774

When doing this, you have to use the option -3to scp, which copies the files through your local machine. Otherwise, scp…

View On WordPress

scp different ssh port

scp different ssh port

image-2584.jpg

http://blog.cripperz.sg/wp-content/uploads/2013/10/linux-tux-logo.jpg scp different ssh ports (one or two different ports)

You can use ~/.ssh/config to specify the ports to use for the hosts (and for setting many other nice things; check the man page man ssh_config):
# ~/.ssh/config

Host 67.12.21.133
Port 6774

Host 67.129.242.40
Port 6774

When…
- Read More from source @ http://blog.cripperz.s…

View On WordPress

scp different ssh port - CP Blog

New Post has been published on http://blog.cripperz.sg/2014/07/26/scp-different-ssh-port/

scp different ssh port

scp different ssh ports (one or two different ports)

You can use ~/.ssh/config to specify the ports to use for the hosts (and for setting many other nice things; check the man page man ssh_config):

# ~/.ssh/config

Host 67.12.21.133
  Port 6774

Host 67.129.242.40
  Port 6774

When doing this, you have to use the option -3 to scp, which copies the files through your local machine. Otherwise, scp issues the scp command via ssh on the first host, so it actually runs

 ssh -p 6774 denny@67.12.21.133 scp -rp /home/denny/testapp1.txt denny@67.129.242.40:

and then the ~/.ssh/config of the first remote host (67.12.21.133) is used instead of your local one.

When you have setup your ~/.ssh/config correctly, this should work:

scp -rp3 denny@67.12.21.133:/home/denny/testapp1.txt denny@67.129.242.40:

Of course, you can also copy the contents of the ~/.ssh/config file onto your first remote host, and then you can use scp without the -3 option, which will probably speeden up the transfer.

Or you can use the trick that scp uses and use such a command line:

ssh -p 6774 denny@67.12.21.133 scp -rp -P 6774 /home/denny/testapp1.txt denny@67.129.242.40:

(Note the different case of the port parameter for ssh and scp: ssh -p 6774 vs. scp -P 6774)

PS: I got this information from the OpenSSH bugzilla where I entered this as a bug: https://bugzilla.mindrot.org/show_bug.cgi?id=2020

Source Article @ http://blog.cripperz.sg/2014/07/26/scp-different-ssh-port/

5 Best Uploading PHP Script Free / Opensource / Freemium

5 Best Uploading PHP Script Free / Opensource / Freemium

There are many file uploading/hosting scripts available in the internet. Today i have collected 5 best open source file hosting scripts that can help you create a file hosting service easily.

5 Best File Hosting Scripts To Make File Sharing Websites

1. Xfilesharing (Free+Commercial)

XFileSharing Prois SibSoft’s advanced, professional solution for file sharing services. Xfilesharing is most…

View On WordPress

5 Best Uploading PHP Script Free / Opensource / Freemium

5 Best Uploading PHP Script Free / Opensource / Freemium

image-2582.jpg

http://blog.cripperz.sg/wp-content/uploads/2012/10/cpavatarwhite120x1201.png There are many file uploading/hosting scripts available in the internet. Today i have collected 5 best open source file hosting scripts that can help you create a file hosting service easily.
5 Best File Hosting Scripts To Make File Sharing Websites
1. Xfilesharing…
- Read More from source @ http://blog.cripperz.sg/2014/…

View On WordPress

5 Best Uploading PHP Script Free / Opensource / Freemium - CP Blog

New Post has been published on http://blog.cripperz.sg/2014/07/25/5-best-uploading-php-script-free-opensource-freemium/

5 Best Uploading PHP Script Free / Opensource / Freemium

There are many file uploading/hosting scripts available in the internet. Today i have collected 5 best open source file hosting scripts that can help you create a file hosting service easily.

5 Best File Hosting Scripts To Make File Sharing Websites

1. Xfilesharing (Free+Commercial)

XFileSharing Pro is SibSoft’s advanced, professional solution for file sharing services. Xfilesharing is most recommended file hosting script.With XFileSharing’s upload system you can upload multiple files simultaneously. You get a visual representation of files that have been loaded, as well as what is currently uploading. Password authentication allows your users to protect all of their sensitive upload data. Users can send links to recently uploaded files to their friends or themselves. For popular websites with heavy file transfer traffic, you can add as many additional servers as you need. Additional file servers can be located on different host networks  they can even be in different countries. XFileSharing Pro will aggregate the power of all your servers for ultra-quick file transfers for uploads and downloads.

Demo
2.Oxishare (Free+commercial)

With OxiShare, you can setup a fully functional and advanced file hosting site within minutes and earn profits through showing advertisements on your site, download pages and more. OxiShare fully supports PayPal IPN and MoneyBookers to take payments from users wanting to upgrade to a premium account. In the future more payment methods will be introduced.

Demo

3. Uploadscript (Commercial)

UploadScript is php file hosting script which is  extremely configurable. You can control generic settings, as well as per-group settings (such as restrictions) from a convenient control panel. You can customize the skin and language used throughout the script, the mime-type output (for instance, to show ads on the page displaying an image), group restrictions, and more.

Demo

4.Mega File Hosting Script (Commercial)

Mega File Hosting Script was Built to Handle Large files (500M +) and is designed to be of minimal burden on your server. MFHS has been rigorously tested and designed to handle brutal file sizes and endure lengthy uploading periods without breaking. This alone sets MFHS world’s apart from any competing script.

Demo

5.PHP File Uploader (Free)

PHP File Uploader is an easy to use, hi-performance free File Upload Script which allows you to upload files to web server without refreshing the page. It allows you select and upload multiple files and cancel running uploads, add new files during uploading.

Demo

Bonus list :

Source Article @ http://blog.cripperz.sg/2014/07/25/5-best-uploading-php-script-free-opensource-freemium/

Rsync Examples (Linux Command)

Rsync Examples (Linux Command)

HowTo Use rsync For Transferring Files Under Linux or UNIX

by on December 5, 2006 · 60 comments· LAST UPDATED August 8, 2012

in , ,

How do you install and use rsync to synchronize files and directories from one location (or one server) to another location? – A common question asked by new sys admin.

rsyncis a free software computer program for Unix and Linux…

View On WordPress

Rsync Examples (Linux Command) - CP Blog

New Post has been published on http://blog.cripperz.sg/2014/07/16/rsync-examples-linux-command/

Rsync Examples (Linux Command)

HowTo Use rsync For Transferring Files Under Linux or UNIX

by on December 5, 2006 · 60 comments· LAST UPDATED August 8, 2012

in , ,

How do you install and use rsync to synchronize files and directories from one location (or one server) to another location? – A common question asked by new sys admin.

rsync is a free software computer program for Unix and Linux like systems which synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate. An important feature of rsync not found in most similar programs/protocols is that the mirroring takes place with only one transmission in each direction.

So what is unique about the rsync command?

It can perform differential uploads and downloads (synchronization) of files across the network, transferring only data that has changed. The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network connection.

How do I install rsync?

Use any one of the following commands to install rsync. If you are using Debian or Ubuntu Linux, type the following command:
# apt-get install rsync
OR
$ sudo apt-get install rsync
If you are using Red Hat Enterprise Linux (RHEL) / CentOS 4.x or older version, type the following command:
# up2date rsync
RHEL / CentOS 5.x or newer (or Fedora Linux) user type the following command:
# yum install rsync

Always use rsync over ssh

Since rsync does not provide any security while transferring data it is recommended that you use rsync over ssh session. This allows a secure remote connection. Now let us see some examples of rsync command.

Comman rsync command options

  • --delete : delete files that don’t exist on sender (system)
  • -v : Verbose (try -vv for more detailed information)
  • -e "ssh options" : specify the ssh as remote shell
  • -a : archive mode
  • -r : recurse into directories
  • -z : compress file data

Task : Copy file from a local computer to a remote server

Copy file from /www/backup.tar.gz to a remote server called openbsd.nixcraft.in
$ rsync -v -e ssh /www/backup.tar.gz jerry@openbsd.nixcraft.in:~
Output:

Password:
sent 19099 bytes  received 36 bytes  1093.43 bytes/sec
total size is 19014  speedup is 0.99

Please note that symbol ~ indicate the users home directory (/home/jerry).

Task : Copy file from a remote server to a local computer

Copy file /home/jerry/webroot.txt from a remote server openbsd.nixcraft.in to a local computer’s /tmp directory:
$ rsync -v -e ssh jerry@openbsd.nixcraft.in:~/webroot.txt /tmp

Task: Synchronize a local directory with a remote directory

$ rsync -r -a -v -e "ssh -l jerry" --delete /local/webroot openbsd.nixcraft.in:/webroot

Task: Synchronize a remote directory with a local directory

$ rsync -r -a -v -e "ssh -l jerry" --delete openbsd.nixcraft.in:/webroot/ /local/webroot

Task: Synchronize a local directory with a remote rsync server or vise-versa

$ rsync -r -a -v --delete rsync://rsync.nixcraft.in/cvs /home/cvs
OR
$ rsync -r -a -v --delete /home/cvs rsync://rsync.nixcraft.in/cvs

Task: Mirror a directory between my “old” and “new” web server/ftp

You can mirror a directory between my “old” (my.old.server.com) and “new” web server with the command (assuming that ssh keys are set for password less authentication)
$ rsync -zavrR --delete --links --rsh="ssh -l vivek" my.old.server.com:/home/lighttpd /home/lighttpd

Read related previous articles

Other options – rdiff and rdiff-backup

The rdiff command uses the rsync algorithm. A utility called rdiff-backup has been created which is capable of maintaining a backup mirror of a file or directory over the network, on another server. rdiff-backup stores incremental rdiff deltas with the backup, with which it is possible to recreate any backup point. Next time I will write about these utilities.

rsync for Windows Server/XP/7/8

Please note if you are using MS-Windows, try any one of the program:

  1. DeltaCopy
  2. NasBackup
Further readings

=> Read rsync man page
=> Official rsync documentation

Source Article @ http://blog.cripperz.sg/2014/07/16/rsync-examples-linux-command/

Xen Server console to vm via command line / CLI

Xen Server console to vm via command line / CLI

How to get console on linux domU with XenServer (xm console equivlent)

Besides the gui/vnc con­soles you can still use the equiv­lent of xm con­sole in Cit­rix XenServer.

On the host console:

  • xe vm-list to get the list of domins run­ning (just note the uuid of the domain you want).
  • list_domains will list the domain name and the uuid of the domains. Match up your uuid so you get the proper dom_id

View On WordPress

Xen Server console to vm via command line / CLI - CP Blog

New Post has been published on http://blog.cripperz.sg/2014/06/27/xen-server-console-vm-via-command-line-cli/

Xen Server console to vm via command line / CLI

How to get console on linux domU with XenServer (xm console equivlent)

Besides the gui/vnc con­soles you can still use the equiv­lent of xm con­sole in Cit­rix XenServer.

On the host console:

  • xe vm-list to get the list of domins run­ning (just note the uuid of the domain you want).
  • list_domains will list the domain name and the uuid of the domains. Match up your uuid so you get the proper dom_id
  • xm con­sole equiv­lent is /usr/lib/xen/bin/xenconsole dom_id

Its not in the root users $PATH though I think it ought to be. Of course you can sym­link it or alter your path your­self but it would be a sen­si­ble default.

Exam­ple:

xen01 = dom0

knox = lin­uxpv domU

Say I want to con­nect to knox (a linux domU)

1
2
3
4
5
6
7
8
9
10
11
12
[root@xen01 ~]# xe vm-list
uuid ( RO)           : 8258a6d4-23f6-003d-30d7-65bd13086863
name-label ( RW): knox
power-state ( RO): running
uuid ( RO)           : 1a191475-a99d-7a77-6550-b30a0038fd92
name-label ( RW): Windows Server 2008 SP2 x86
power-state ( RO): halted
uuid ( RO)           : ffd95724-d818-4f15-b4b4-159b7ff41df4
name-label ( RW): Control domain on host: xen01
power-state ( RO): running

Now get domain ids

1
2
3
4
5
6
[root@xen01 ~]# list_domains
id |                                 uuid |  state
0 | ffd95724-d818-4f15-b4b4-159b7ff41df4 |     R
1 | bc150966-8c21-7ad9-c329-839d5823041d |    B H
7 | baa3699b-95dd-eea0-ccc4-51e8972857f5 |    B
11 | 8258a6d4-23f6-003d-30d7-65bd13086863 |    B

You can see the domain ID that matches the UUID of knox is 11. So we use xenconsole.

1
2
3
4
[root@xen01 ~]# /usr/lib/xen/bin/xenconsole 11
(press enter)
You have new mail in /var/spool/mail/root
[root@knox ~]#

Source Article @ http://blog.cripperz.sg/2014/06/27/xen-server-console-vm-via-command-line-cli/

Setting up network alias in BSD (openBSD / freeBSD)

Setting up network alias in BSD (openBSD / freeBSD)

FreeBSD
  1. Find the Interface
  2. Set a Temporary IP Alias
  3. Set a Permanent IP Alias
  4. Remove an IP Alias
OpenBSD
  1. Find the Interface
  2. Set an IP Alias
  3. Make the IP Alias Permanent
  4. Remove an IP Alias

FreeBSD

Find the Interface

If you want to put an IP alias on an interface under FreeBSD, first find the interface:

 FreeBSD# ifconfig 
 em0: flags=8843 metric 0 mtu 1500 options=19b ether 00:1c:25:74:af:69 inet…

View On WordPress

Setting up network alias in BSD (openBSD / freeBSD) - BLog.CripperZ.SG

New Post has been published on http://blog.cripperz.sg/2014/06/26/setting-network-alias-bsd-openbsd-freebsd/

Setting up network alias in BSD (openBSD / freeBSD)

FreeBSD

  1. Find the Interface
  2. Set a Temporary IP Alias
  3. Set a Permanent IP Alias
  4. Remove an IP Alias

OpenBSD

  1. Find the Interface
  2. Set an IP Alias
  3. Make the IP Alias Permanent
  4. Remove an IP Alias

FreeBSD

Find the Interface

If you want to put an IP alias on an interface under FreeBSD, first find the interface:

 FreeBSD# ifconfig 
 em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
         options=19b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4>
         ether 00:1c:25:74:af:69
         inet 192.168.1.200 netmask 0xffffff00 broadcast 192.168.1.255
         media: Ethernet autoselect (100baseTX <full-duplex>)
         status: active
 lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
         inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 
         inet6 ::1 prefixlen 128 
         inet 127.0.0.1 netmask 0xff000000 

In our case the interface is called em0. We will use this name in all the examples. Replace it with the interface name you find on your system!

Set a Temporary IP Alias

Then set the alias with ifconfig

 FreeBSD# ifconfig em0 192.168.100.200 netmask 255.255.255.0 alias

This sets an IP address 192.168.100.200 to em0. Check again with ifconfig:

 FreeBSD# ifconfig
 em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
         options=19b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4>
         ether 00:1c:25:74:af:69
         inet 192.168.1.200 netmask 0xffffff00 broadcast 192.168.1.255
         inet 192.168.100.200 netmask 0xffffff00 broadcast 192.168.100.255
         media: Ethernet autoselect (100baseTX <full-duplex>)
         status: active
 lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
         inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 
         inet6 ::1 prefixlen 128 
         inet 127.0.0.1 netmask 0xff000000 

Now we see two IP addresses on em0. If you want to set an IP address within the same network you would have to set a fake netmask of 255.255.255.255.

Set a Permanent IP Alias

The above alias will be lost after the next reboot. If you need a permanent alias, add the following line to /etc/rc.conf:

 ifconfig_em0_alias0="192.168.100.200 netmask 255.255.255.0"

and restart the network:

 FreeBSD# /etc/rc.d/netif restart && /etc/rc.d/routing restart

Remove an IP Alias

To remove the alias (until next reboot, if you made it permanent), just remove the IP address from the interface you put on it earlier:

 FreeBSD# ifconfig em0 192.168.100.200 delete

OpenBSD

Setting an IP alias to an interface with OpenBSD is straight forward:

Find the Interface

First find the interface you want to put an IP alias with ifconfig:

 OpenBSD# ifconfig
 lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33208
         groups: lo
         inet 127.0.0.1 netmask 0xff000000
         inet6 ::1 prefixlen 128
         inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
 vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
         lladdr 00:40:45:28:89:37
         groups: egress
         media: Ethernet autoselect (100baseTX full-duplex)
         status: active
         inet 192.168.1.199 netmask 0xffffff00 broadcast 192.168.1.255
         inet6 fe80::240:45ff:fe28:8937%vr0 prefixlen 64 scopeid 0x2

From the above output you see that your current IP address is put on vr0. We will use this name in all the examples. Replace it with the interface name you find on your system!

Set an IP Alias

To put a second IP address to the same interface, just enter on the commandline as root:

 OpenBSD# ifconfig vr0 inet alias 192.168.100.199 netmask 255.255.255.0

This sets an IP address 192.168.100.199 to vr0. Check again with ifconfig:

 OpenBSD# ifconfig -A
 lo0: flags=8049 mtu 33208
         groups: lo
         inet 127.0.0.1 netmask 0xff000000
         inet6 ::1 prefixlen 128
         inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
 vr0: flags=8843 mtu 1500
         lladdr 00:40:45:28:89:37
         groups: egress
         media: Ethernet autoselect (100baseTX full-duplex)
         status: active
         inet 192.168.1.199 netmask 0xffffff00 broadcast 192.168.1.255
         inet6 fe80::240:45ff:fe28:8937%vr0 prefixlen 64 scopeid 0x2
         inet 192.168.100.199 netmask 0xffffff00 broadcast 192.168.100.255

Now we see two IP addresses on vr0. If you want to set an IP address within the same network you would have to set a fake netmask of 255.255.255.255.

Make the IP Alias Permanent

If you use ifconfig to set an IP alias, the alias won’t be present after the next reboot. To make the setting permanent, add a line to /etc/hostname.<INTERFACE>:

 OpenBSD# vi /etc/hostname.vr0
 inet 192.168.1.199 255.255.255.0 NONE 
         inet alias 192.168.100.199 255.255.255.0

Remove an IP Alias

You can remove an IP alias with a comand like this:

 OpenBSD# ifconfig vr0 192.168.100.199 delete

This deletes the second IP address from the interface keeping the first.

Source: UnixWerk

Source Article @ http://blog.cripperz.sg/2014/06/26/setting-network-alias-bsd-openbsd-freebsd/

Postfix empty / delete all mail queue command line

Postfix empty / delete all mail queue command line

Empty Postfix Mail Queue

This command will delete one specific email from the mailq (taken from the postsuper man page) mailq
| tail +2 | grep -v ‘^ *(‘ | awk ‘BEGIN { RS = “” } { if ($8 ==
“email@address.com” && $9 == “”) print $1 } ‘ | tr -d ‘*!’ |
postsuper -d -

I use a few scripts that check the status of our servers and email/page me if they don’t respond. This led to a problem when I was…

View On WordPress

Postfix empty / delete all mail queue command line - BLog.CripperZ.SG

New Post has been published on http://blog.cripperz.sg/2014/06/19/postfix-empty-delete-mail-queue-command-line/

Postfix empty / delete all mail queue command line

Empty Postfix Mail Queue

This command will delete one specific email from the mailq (taken from the postsuper man page)


I use a few scripts that check the status of our servers and email/page me if they don’t respond. This led to a problem when I was offline for one reason or another. I would get a ton of messages sent to the postfix queue which would all be sent out when I reconnected to the internet. Deleting the postfix mail Queue is suprisingly easy: This command will delete all messages in the Postfix queue. If you need more selective deleting, this can be done as well, use ‘man postsuper’ to find out all of the available options.


The other thing that helped with this was checking for a local network connection before doing the server checks. This is done with the following.

Source Article @ http://blog.cripperz.sg/2014/06/19/postfix-empty-delete-mail-queue-command-line/

How to delete million of files on busy Linux servers (rm -f *: Argument list too long)

How to delete million of files on busy Linux servers (rm -f *: Argument list too long)

How to delete million of files on busy Linux servers (rm -f *: Argument list too long)

If you try to delete more than 131072 of files on Linux with rm -f *, where the files are all stored in the same directory, you will get an error:

/bin/rm: Argument list too long.

I’ve earlier blogged on deleting multiple files on Linux and FreeBSD and this is not my first time facing this error.
Anyways, as…

View On WordPress